Solved

Set TextBox Maxlength property in formview dynamically

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

813 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

18 Experts available now in Live!

Get 1:1 Help Now