[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 693
  • Last Modified:

Set TextBox Maxlength property in formview dynamically

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
WingYip
Asked:
WingYip
1 Solution
 
BuggyCoderCommented:
0
 
Ronak PatelCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now