I have a SharePoint Visual WebPart with a Button on it.
WebPart's .ascx
<asp:Button ID="btnGo" CssClass="ms-ButtonHeightWidth" Text="Apply" runat="server" OnClick="BtnAppyClick"/>
On Button Click the event BtnAppyClick gets fired. I also have commented out all the code snippets which i tried.
protected void BtnAppyClick(object sender, EventArgs e)
{
try
{
// Page.Response.Write("<script language='JavaScript'>alert('The 60 seconds.')</script>");
//string script = "<script language='javascript'>alert('The 60 seconds.')</script>";
//Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert_box", script);
//ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert_box", "alert('The 60 seconds.')", true);
ClientScriptManager csm = Page.ClientScript;
csm.RegisterClientScriptBlock(this.GetType(), "alert_box", "<script type=\"text/javascript\" language=\"javascript\">alert('The 60 seconds.');</script>", true); }
catch (Exception se)
{
lbError.Text = BuildErrorMsg(se);
}
}
I simply want to show a Javascript alert box on Button click, but this doesnt work. When i debug my solution the event is getting executed and there is no error.
What is wrong here? And to show, that my code is executing the Button OnClick Event, here is a screenshot which shows that it steps into the event and i could go step by step through the code without any errors:
