show warning message to user in ASP.NET
I have a pop up window that is create in run time, and can have several text area. I need to count number of characters of its text area and show warning to users if they pass maximum number. the application wrote by ASP.NET. I can't use "onClientClick", because I don't know the name of the text area, they created run time and I save their name in a dictionary that just have in server side. I tried to use "RegisterStartupScript" to call java script "alert" method but it doesn't work.开发者_StackOverflow社区 In fact it works but it execute all the save code and show alert after that. but I want to execute save code after user confirmation. I think to open message box with jquery but my current windows is opening with AJAX and it won't nice to open another AJAX page. Can You help me and show me the way to show warning, or solving my problem.
You need to use the onkeypress or onkeyup events in the text area, and use a function like this to show the warning:
onkeypress="checkLength(this, 200);"
And the JavaScript function:
checkLength = function(input, maxLength){
if (input.value.length > maxLength)
alert('Length exceeds maximum');
}
精彩评论