Calling Javascript function from code behind

Sandhyab
Posted by Sandhyab under JavaScript category on | Points: 40 | Views : 1234
  <asp:TextBox ID="TextBox1" runat="server"  AutoPostBack="true" OnTextChanged="Click"></asp:TextBox>

Javascript:
  <script type="text/javascript" language="javascript">     
function validate(msg) {
var text1 = document.getElementById("divtext");
if (msg == "y")
{
text1.style.color = 'Green';
}
else
{
text1.style.color = 'Red';
}
}
</script>

Code Behind
 protected void Click(object sender, EventArgs e)
{
string msg = TextBox1.Text.Trim();
string fun = "validate('" + msg + "')";
ScriptManager.RegisterStartupScript(Page, typeof(Page), "Validate", fun, true);
}


Thanks & Regards

Comments or Responses

Posted by: Samarmir on: 11/24/2012 Level:Starter | Status: [Member] | Points: 10
What is this? What are you trying to do?

Login to post response