Solved

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

Posted on 2014-09-30
2
178 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decadeā€¦

710 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