Solved

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

Posted on 2014-09-30
2
184 Views
Last Modified: 2014-10-02
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
Comment
Question by:pzozulka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
draek earned 250 total points
ID: 40354068
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
 
LVL 32

Assisted Solution

by:Robberbaron (robr)
Robberbaron (robr) earned 250 total points
ID: 40354098
yes, you need to provide more details about the custom control
i1Textbox
as i cant find any references to it elsewhere.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

624 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