Hi,
i have a curious problem. I have a already developed Visual WebPart and a Button on it. This Button has an Server Side OnClick Event which works fine. I need to add new functionality to it so that after the action in the onClick Event is finished, i need to show a messagebox (Javascript alert).
I tried everything what i also used in the past for example in Custom Application Pages but none of the code snippets worked. I also have googled around but had no luck.
This is my .ascx code for the Button
<asp:Button ID="btnGo" CssClass="ms-ButtonHeightWidth" Text="Apply" runat="server" OnClick="BtnAppyClick"/>
This is my onClick Event for the Button
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);
}
}This is the proof that my onClick event works fine. As you can see from my code, i tried several ways to show the alert message, but without success.
I simply want to show a Javascript alert box on Button click from server side code, but this doesnt work. When i debug my solution the event is getting executed and there is no error.
What is wrong here? I think the problem must be theVisual WebPart! But i have no idea how to get it working.
Best regards,
Yavuz B.
My Sharepoint and Enterprise 2.0 Blog http://www.bogazci.com |Microsoft Sharepoint Resources & Blog List