C# – Get number of character selected in a multiline textbox in asp.net

asp.netcmultilinetextbox

Hai Guys,
I have a multiline textbox and I have set MaxLength="160" ,also i have a label indicating number of characters remaining…. Now i want to get the number of characters selected by the user he may delete it and i have to add to the count representing total number of characters left inside that label….. I want this to be done in the Text_Changed event of the textbox

Best Answer

To do this client side use javascript, a solution for that is shown here. To do it in a server side event handler, just get the length of the string, by the time your page has been posted back to the server the highlight has gone.

Related Topic