Click here to Skip to main content
16,004,906 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Form Authentication Pin
Parwej Ahamad17-Sep-07 22:06
professionalParwej Ahamad17-Sep-07 22:06 
GeneralRe: Form Authentication [modified] Pin
bhattiprolu17-Sep-07 22:11
bhattiprolu17-Sep-07 22:11 
Questionbrowsing the web pages in the virtual directoy/local host Pin
Sonia Gupta17-Sep-07 19:52
Sonia Gupta17-Sep-07 19:52 
AnswerRe: browsing the web pages in the virtual directoy/local host Pin
saini arun17-Sep-07 21:06
saini arun17-Sep-07 21:06 
GeneralRe: browsing the web pages in the virtual directoy/local host Pin
Sonia Gupta17-Sep-07 21:14
Sonia Gupta17-Sep-07 21:14 
GeneralRe: browsing the web pages in the virtual directoy/local host Pin
saini arun17-Sep-07 21:50
saini arun17-Sep-07 21:50 
GeneralRe: browsing the web pages in the virtual directoy/local host Pin
Sonia Gupta17-Sep-07 22:19
Sonia Gupta17-Sep-07 22:19 
Questionhow can apply maxLength limit in textBox when is TextMode="MultiLine" ? [modified] Pin
B.A17-Sep-07 19:40
B.A17-Sep-07 19:40 
hi ...<br />
i want to apply max length limit in textBox control in asp.net when set textMode="muliline" .<br />
<br />
i search in internet and get follow description from : http://www.google.com/url?sa=t&ct=res&cd=3&url=http%3A%2F%2Fwww.karamasoft.com%2FWhitePapers%2FJavaScript-Tips-Part1.pdf&ei=ZYPuRri_KZy2QaigzM4F&usg=AFQjCNFZxFGslWcb9UbApb2eQjqCRZB00w&sig2=AI2pBC2KYzcO6xwn3R-sTQ<br />




HTML input type of text element provides a built-in MaxLength property to set the maximum number of characters that the user can enter. However, the TextArea element does not have such property to limit the number of characters that can be entered. When you have an ASP.NET TextBox control with TextMode="MultiLine" in your web page, it is rendered as an HTML TextArea element and you cannot use MaxLength property to set the maximum number characters.

What you can do is to define a keypress event handler for the TextBox control to check the length of the text inside the text area and cancel the event if the MaxLength is reached.

JavaScript
function ValidateMaxLength(evnt, str, maxLength) {
var evntKeyCode = GetEventKeyCode(evnt);
// Ignore keys such as Delete, Backspace, Shift, Ctrl, Alt, Insert, Delete, Home, End, Page Up, Page Down and arrow keys
var escChars = ",8,17,18,19,33,34,35,36,37,38,39,40,45,46,";
if (escChars.indexOf(',' + evntKeyCode + ',') == -1) {
if (str.length >= maxLength) {
alert("You cannot enter more than " + maxLength + " characters.");
return false;
}
}
return true;
}

ASPX
<asp:textbox id="txtValidateMaxLength" runat="server" textmode="MultiLine">

C#
protected void Page_Load(object sender, EventArgs e)
{
txtValidateMaxLength.Attributes.Add("onkeypress", "return ValidateMaxLength((window.event) ? window.event : arguments[0], this.value, 5)");
}



<br />
but when i execute it doesn't work . <br />
i think the problem is in first parameter of "ValidateMaxLength" method !!! 


can you help me ?Confused | :confused:



-- modified at 1:46 Tuesday 18th September, 2007
AnswerRe: how can apply maxLength limit in textBox when is TextMode=&amp;quot;MultiLine&amp;quot; ? Pin
Jintal Patel17-Sep-07 21:46
Jintal Patel17-Sep-07 21:46 
Questiondatabase is accessed by the vb6 application and website Pin
Sonia Gupta17-Sep-07 19:21
Sonia Gupta17-Sep-07 19:21 
QuestionHow to Change the Width of dropdown List Dynamic Pin
Jintal Patel17-Sep-07 19:12
Jintal Patel17-Sep-07 19:12 
AnswerRe: How to Change the Width of dropdown List Dynamic Pin
Sonia Gupta17-Sep-07 19:27
Sonia Gupta17-Sep-07 19:27 
GeneralRe: How to Change the Width of dropdown List Dynamic Pin
Jintal Patel17-Sep-07 21:20
Jintal Patel17-Sep-07 21:20 
AnswerRe: How to Change the Width of dropdown List Dynamic Pin
Imran Khan Pathan17-Sep-07 19:37
Imran Khan Pathan17-Sep-07 19:37 
QuestionVS 2005 Migration issue Pin
vikram reddy pullimamidi17-Sep-07 19:02
vikram reddy pullimamidi17-Sep-07 19:02 
AnswerRe: VS 2005 Migration issue Pin
Parwej Ahamad17-Sep-07 19:25
professionalParwej Ahamad17-Sep-07 19:25 
GeneralRe: VS 2005 Migration issue Pin
vikram reddy pullimamidi18-Sep-07 22:23
vikram reddy pullimamidi18-Sep-07 22:23 
QuestionHow to do this in AJAX Pin
varshavmane17-Sep-07 18:55
varshavmane17-Sep-07 18:55 
QuestionHyper Link Pin
S A R I T H17-Sep-07 18:42
S A R I T H17-Sep-07 18:42 
AnswerRe: Hyper Link Pin
Parwej Ahamad17-Sep-07 19:29
professionalParwej Ahamad17-Sep-07 19:29 
GeneralRe: Hyper Link Pin
S A R I T H17-Sep-07 20:42
S A R I T H17-Sep-07 20:42 
QuestionReport Builder Pin
Kavitha.Sivalingam17-Sep-07 18:11
Kavitha.Sivalingam17-Sep-07 18:11 
QuestionCustom Validator for validate string Pin
ybasha17-Sep-07 16:13
ybasha17-Sep-07 16:13 
AnswerRe: Custom Validator for validate string Pin
ybasha17-Sep-07 16:57
ybasha17-Sep-07 16:57 
GeneralRe: Custom Validator for validate string Pin
ybasha17-Sep-07 17:51
ybasha17-Sep-07 17:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.