Solved

Set TextBox Maxlength property in formview dynamically

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hangfire / asp.net sample 3 50
Set cookies HttpOnly and Secure 4 111
ASP.net VB.net Object not set to an instance of an object 4 33
How do ASP.NET and MVC work together? 4 27
AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 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

21 Experts available now in Live!

Get 1:1 Help Now