dhj Posted January 9, 2004 Posted January 9, 2004 hi i need to redirect the browser to the original page i was in a web application under C# .net environment thx Quote
bungpeng Posted January 9, 2004 Posted January 9, 2004 What do you mean original page? your current page? then you may try request.redirect or server.transfer Quote
dhj Posted January 9, 2004 Author Posted January 9, 2004 hi bungpeng thx for replying what i need to do is this say i'm currently in a page called A.aspx in a href i'm calling a page called B.aspx after doing some code there (in page B) i need to go back to the page A.aspx and i want the the data which exist earlier in the page A i cannot use redirect fo rhtis cos page A contain query strings Quote
bungpeng Posted January 9, 2004 Posted January 9, 2004 Work like browser "Back" function? using Javascript: history.back() Is that what you want? Quote
dhj Posted January 9, 2004 Author Posted January 9, 2004 that is exactly what i want but i cannot use javascript is there a method to do this in C# if so pls let me know thx Quote
bungpeng Posted January 9, 2004 Posted January 9, 2004 You cannot use javascript? why? Because C# is server site language and javascript is client site language, you cannot do this using server site language. The advantage of javascript is it support by all type of browsers & it is free. I don't know why can't you use it... Quote
skrampe Posted January 9, 2004 Posted January 9, 2004 Try a parameter with the return URL I use the following code to update my main page when i update data in a popup-window: Open the popup-window wiht a parameter: ....FilterPage.aspx?BaseURL="contact_tab.aspx&ID=xyz".... Take care you have to replace the "&" In the popUp: ... sRet = Request.QueryString("baseURL") .... To close the PopUp and reload to the original page: (You can also define a link so that you don't have to do a postback) .... RegisterClientScriptBlock("JS_Go", JavaScript.closePopUp(sret)) JavaScript.closePopUp is defined by me, because i don't like JavaScript (especially in my code) ;) Here's the definition: Const START_JS_TAG = "<script language='JavaScript'>" Const END_JS_TAG = "</script>" Const START_JS_LINK = "javaScript:" Const END_JS_LINK = "" Public Function closePopUp(Optional ByVal sBaseURL As String = Nothing, Optional ByVal AsLink As Boolean = False) As String Dim tmpString As String tmpString = IIf(AsLink, START_JS_LINK, START_JS_TAG) If Not IsNothing(sBaseURL) Then 'Seite neu aufrufen tmpString += "window.opener.location.href='" & sBaseURL & "';" End If tmpString += "window.close();" tmpString += IIf(AsLink, END_JS_LINK, END_JS_TAG) Return tmpString End Function Quote
dhj Posted January 9, 2004 Author Posted January 9, 2004 i have been told to use only C# and not javascript so is it possible to do this in C# Quote
skrampe Posted January 9, 2004 Posted January 9, 2004 yes it is Yes! The gist is: Save the URL (querystring) somewhere you like it and where you can access it from "B" page. In the "B" page you can read your URL (querystring) and do a Server.transfer or whatever you want. What i do: I'm saving the querysting into a querystring. Sure, you can do it much easier. Quote
dhj Posted January 13, 2004 Author Posted January 13, 2004 thank you very much i did it using querystrings thx all Quote
vbFace Posted January 13, 2004 Posted January 13, 2004 You could also save Page A's info in the Session Object, although if the number of data items is large, it could be a mess. You CAN create a class/DLL in C# and assign that class to the Session object. Check out this thread: http://www.xtremedotnettalk.com/showthread.php?s=&threadid=81560 Then, you can just use Response.Redirect("PageA.aspx") to navigate without querystrings. Basically, it would depend on the number of data items. Quote
samsmithnz Posted January 13, 2004 Posted January 13, 2004 Sessions always become a mess, dispite the promises they seem to make. I recommend keeping the querystring method, and only using session variables for good reasons and only when you actually need them... Quote Thanks Sam http://www.samsmith.co.nz
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.