Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

I am getting few data from input form and inserting into a table.
After inserting I want to completely post the page from C#.

I have coded as below:
C#
//Since I have used Update Panel - For Alert i have used ScriptManager.RegisterClientScriptBlock.
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientscript", "alert('Your details have successfully registered with us. Kindly check your mail inbox to login.')", true);
Response.Redirect("Opp_As_DSA.aspx");

Its work but Alert Message is not dispalyed.
Kindly Suggest or Guide me on the same.
Posted
Updated 12-Oct-12 3:45am
v2

The code is working perfectly. The code
C#
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientscript", "alert('Your details have successfully registered with us. Kindly check your mail inbox to login.')", true);


actually registers the javascript and does not fire it. You need to find other way to display the alert from client side. I can not suggest you more on this since you have provided a very little information on this.

Nextly, since you are redirecting the page using
C#
Response.Redirect("Opp_As_DSA.aspx");
, the alert will be displayed and not visible to you because of the redirection.
 
Share this answer
 
Comments
I.explore.code 12-Oct-12 10:22am    
precisely! I personally don't even prefer pop-ups, so i would use just a simple label to show that message and then redirect the user. For such a simple behavior doing a RegisterClientScriptBlock seems an overkill. +5!
bbirajdar 12-Oct-12 10:36am    
I agree with you Aman.. I personally don't like the unskinnable and colourless javascript alert box. A jquery popup or a themed label looks gorgeous...Thanks
Its work fine for my requirement but I don't know weather it is proper way of using it.

ScriptManager.RegisterStartupScript(Page, Page.GetType(), "MessageThenRedirect", "alert('Failure Report - Try Later.');window.location='Opp_As_DSA.aspx';", true);
 
Share this answer
 
Just Use this blow script after the insert Statement in .cs page

JavaScript
Page.RegisterStartupScript(@"SubmitRegistration", "<script>alert('Your details have successfully registered with us. Kindly check your mail inbox to login')</script>");
 
Share this answer
 
Please replace the this with Page
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "clientscript", "alert('Your details have successfully registered with us. Kindly check your mail inbox to login.')", true);

Hope this will help you
Thanks
 
Share this answer
 
Comments
Arunprasath Natarajan 12-Oct-12 10:31am    
Sorry Its Not Working
bbirajdar 12-Oct-12 10:36am    
How will you see the popup if you redirect to another page just after showing the popup.... Morever the code for popup is wrong...
I.explore.code 12-Oct-12 10:43am    
well, the popup won't even show because the script has only been registered it hasn't had time to execute yet and before it does, Response.Redirect moves the user to a different page.
Arunprasath Natarajan 12-Oct-12 10:46am    
Thank you for your suggestions, Shall I prefer Window.location()
bbirajdar 12-Oct-12 11:16am    
Remove response.redirect and test the popup first.. If it works , then you have next things to do..

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