Solved

Set TextBox Maxlength property in formview dynamically

Posted on 2012-03-27
2
636 Views
Last Modified: 2012-08-13
VS 2010, .Net 4, Asp.Net

Hi
I need to be able to set the maxlength property of every textbox in the insertitem template of a formview, dynamically using the bound field's sql datatype and length (I am using a linq datasource) - I only need to do this for nchars and nvarchars.

Is there any way to do this at runtime?

Thanks

Wing
0
Comment
Question by:WingYip
2 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37775370
0
 
LVL 5

Expert Comment

by:Ronak Patel
ID: 37775376
attach below javascript code to textbox's event to dynamically change it's maxlength property.

TextBox1.Attributes.Add("onfocus", "return this.maxLength = 50;");

Open in new window

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now