Handle OnClick in Jquery or C# I am working on a webforms project using c#/aspx/jquery. I'm not sure where to handle my Onclick. Both options (doing it in C# or jquery) seem feasible. Which would be better practice?

Here is the scenario:

I want to build a checkbox which will toggle a textbox's textmode, altering it between Password and SingleLine.

Currently, I have this following code for my markup since I am currently handling it in C#:

&lt;asp:Checkbox ID="CheckBox1" OnCheckedChanged="CheckBox1_OnCheckedChanged"/&gt;


The code:

protected virtual void OnCheckedChange(EventArgs e)
{
     If (CheckBox1.TextMode == TextMode.Password)
          CheckBox1.TextMode = TextMode.SingleLine;
     else
          CheckBox1.TextMode = TextMode.Password;
}


The use case of this is: A user is entering his password. On the same page, he may choose to keep the password hidden or not by checking the checkbox.
You cannot change the type of the input field on client side in some or all browsers. I would create a custom hiding method in Javascript and leave the input type in text mode (SingleLine), but maybe this has some drawbacks in security.

Other solution is to remove the original input and create a new one on the fly with Javascipt but i think not all browser will let you to read out the value of a password type input.

Third version is to send the field to the server side and get back the new HTML fields but in this way you may send multiple times the password to the server which can be a security hole.