[Webinar] Streamline your web hosting managementRegister Today

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

ASP.NET & C#: Modify the character limit of a textbox

Currently, a textbox is set to allow 50 characters. I need to limit it to 40 characters. None of my below attempts seem to be working:

I tried doing this in the ascx.cs file:
txtName1.MaxLength = 40;

I also tried doing this in the .ascx file:
<TD class="ControlLayoutCell"><cc1:i1textbox id="txtName1" tabIndex="2" runat="server" Text="" Width="100%" MaxLength="40"><LabelStyle CssClass="TextBoxEditDisabled"></LabelStyle>
													<TextBoxStyle CssClass="TextBoxGeneric"></TextBoxStyle>
												</cc1:i1textbox></TD>

Open in new window

0
pzozulka
Asked:
pzozulka
2 Solutions
 
draekCommented:
You are using a custom textBox class or something? I'm asking this because the default component will act as you like, so if you're doing textBox1.MaxLength will do the job.
0
 
Robberbaron (robr)Commented:
yes, you need to provide more details about the custom control
i1Textbox
as i cant find any references to it elsewhere.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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