Reputation: 21188
Why does this statement work with OnKeyPress event of Javascript in C#.
txtPassword.Attributes.Add("OnKeyUp", "CheckPasswordStrength(\""
+ txtPassword.ClientID.ToString() + "\",\""+ lblMessage.ClientID.ToString() +"\")");
this code is working correctly, my problem is that i want to run keypress event not keyup event
Upvotes: 1
Views: 1986
Reputation: 48088
You should check the rendered output by viewing source of the page but I think your problem is about double quotes. Replace them with single quotes.
txtPassword.Attributes.Add("OnKeyUp", "CheckPasswordStrength('"
+ txtPassword.ClientID.ToString() + "','"+ lblMessage.ClientID.ToString()
+"')");
this will probably rendered as :
<input onkeyup="CheckPasswordStrength('clientIdhere', 'clientIdhere');" />
Upvotes: 1