Solved

Set TextBox Maxlength property in formview dynamically

Posted on 2012-03-27
2
669 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

821 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