I need to implement a functionality in which first I have to show Java Script from code behind file and then user needs to be redirected to other page.
I have used both
this.Context.Response.Write("<script type='text/javascript'>alert('some text')</script>");
and
ClientScriptManager.RegisterStartupScript();
but none of them were showing alert box the code snippet is as :
//approach 1
this.Context.Response.Write("<script type='text/javascript'>alert('some text')</script>");
SPUtility.Redirect(string.Empty, SPRedirectFlags.UseSource, this.Context);
//approach 2
String csname1 = "PopupScript";
Type cstype = this.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, csname1))
{
StringBuilder cstext1 = new StringBuilder();
cstext1.Append("<script type=text/javascript> alert('You do not have Access to perform any action.') </");
cstext1.Append("script>");
cs.RegisterStartupScript(cstype, csname1, cstext1.ToString());
}
SPUtility.Redirect(string.Empty, SPRedirectFlags.UseSource, this.Context);
but none of them shows alert box
Please help me out