Click to See Complete Forum and Search --> : question about response.write/redirect
zezebox
August 21st, 2010, 11:51 PM
how can i use these two commands together when i try it it works but the redirect activates before i can see my write. for example when i click my update button inside the code i would put all the stuff i want to send to a database, but if an error occurs i want to reply with a message then redirect after the user clicks ok on that pop-up. anyways heres the code im using for the .write .redirect:
Response.Write("<script>alert('Update Unsuccessful');</script>");
Response.Redirect("Page.aspx");
ill have this in an if statement checking for problems if something comes up i want the user to know what they did wrong then it redirects them to the same page.
VictorN
August 22nd, 2010, 02:41 AM
What is Response?
What is Write?
What is Redirect?
What is <script>?
What is the type of application you have the problems with?
:confused:
zezebox
August 22nd, 2010, 02:48 AM
uhh well its a like a commerical web site that stores and updates information from a database. the
Response.Write("<script>alert('Update Unsuccessful');</script>");
creates a pop-up icon with an ok button and a message saying update unsuccessful. this occurs when submit button is clicked
Response.Redirect("Page.aspx");
redirects you to another page in this case the file i am working on is Page.aspx so what i want to happen is when you click submit and get and error how would you create a pop-up letting the user know of the error then refresh the page to clear fields. i cant use MessageBox.Show because my hosting website doesn't support it.
VictorN
August 22nd, 2010, 02:55 AM
Well, it sounds that your code is NOT a Visual C++. Is it?
zezebox
August 22nd, 2010, 03:06 AM
its c#
VictorN
August 22nd, 2010, 03:44 AM
Then why do you ask in C++ Forum? :confused:
Ask it here (http://www.codeguru.com/forum/forumdisplay.php?s=&daysprune=&f=11)!
Igor Vartanov
August 22nd, 2010, 04:11 PM
Besides, I have an impression that the question is more about HTTP stuff rather than C++ or C#. It seems to me, that Redirect has something to do with header, while script is something to be executed at loading. What I'm trying to say is that Page.aspx should implement the said alert, otherwise redirection must be done in the script, by re-assigning location for example.
HanneSThEGreaT
August 26th, 2010, 08:00 AM
how can i use these two commands together when i try it it works but the redirect activates before i can see my write.
Response.Write("<script>alert('Update Unsuccessful');</script>");
Response.Redirect("Page.aspx");
You're wrong. Both happens. Because you are redirecting to another page, that is why you don't see your written text. Why navigate away from the page in the first place?
Set up proper error handling to ensure validity of your data first, then, only once everything is valid, redirect to where you want to. This is basic common exception handling.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.