You have double script tags. Add script tags:
protected void btnAbct_Click(object sender, EventArgs e) {
string script = "<script type=\"text/javascript\">alert('abc');</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script);
}
Or let the method add it:
protected void btnAbct_Click(object sender, EventArgs e) {
string script = "alert('abc');";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true);
}
Not both.
Also consider whether the method is suitable RegisterStartupScriptfor what you want to do.
source
share