Click here to Skip to main content
15,908,661 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Below is the code ,

Issue i have alert message its not displaying it instead control goes to the next line and re-direction happens successfully. when i place the break point it enters the criptManager.RegisterStartupScript but does not display the message. I have tried commenting the response redirect and checked still no go ..

HTML
protected void btnLoadObjectRepository_Click(object sender, ImageClickEventArgs e)
   {




       if (Session["dirtyFlag"].ToString() == "1")
       {
           ScriptManager.RegisterStartupScript(this, typeof(string), "openNewWindow", "<script>alert(You will loose the data create button is not clicked')</script>", false);

       }

       Response.Redirect("LoadObjectRepository.aspx");



   }
Posted
Updated 17-Mar-14 23:38pm
v2

Inside the alert you missed the ' quotes...

C#
ScriptManager.RegisterStartupScript(this, typeof(string), "openNewWindow", "<script>alert('You will loose the data create button is not clicked')</script>", false);
 
Share this answer
 
Comments
ShaHam11 18-Mar-14 5:46am    
thank you but still not working
Hey Buddy,

First of all Apply a jQuery file to the head section of your application.

After this use this code:

Page.ClientScript.RegisterStartupScript(this.GetType(), "func", "window.top.location = ('WebForm1.aspx');", true);


Here in place of window.top.location you can use alert.
 
Share this answer
 
Comments
ShaHam11 18-Mar-14 6:06am    
Hi I tried its not working btw i have already refernece a jquery file in my aspx page
Try this.
C#
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Your Message here');window.location='yourpage.aspx';", true);


it will display the message before you are redirected
 
Share this answer
 
Comments
ShaHam11 18-Mar-14 6:08am    
Hi I tried your above code still not working
Simply, try this,

C#
Response.Write("<script>alert("Your Alert Message..")</script>");
 
Share this answer
 
Comments
santhu888 18-Mar-14 6:46am    
My ans is by using Response.Redirect("LoadObjectRepository.aspx"); it won't show any messages
it automatically gets refreshed no message will be displayed....
ShaHam11 18-Mar-14 7:24am    
I had commented response redirect still it didnt work
Check your
C#
Session["dirtyFlag"]
value first, and check whether the if condition is working or not??
 
Share this answer
 
Comments
ShaHam11 19-Mar-14 1:40am    
yes it works it shows me the string 1 , I checked placing a break point
Manikandan K 19-Mar-14 1:59am    
then Response.Write("<script>alert("Your Alert Message..")</script>") this will work without fail...
ShaHam11 19-Mar-14 2:22am    
Hi I tried i get this erro

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parse

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900