Anchoring to clicked item in asp.net page - asp.net

I've a datagrid on an asp.net page "A" which shows different customer orders.
On clicking on one any row/OrderId,user is redirected to another page "B" which displays order details.
When user clicks "Back to Page A" on page B,I need to have the same order Id "anchored" on page A.
How do i achieve this functionality in asp.net?
Thanks for reading.

Joel's answer is correct, however, if you have a more complicated scenario you could do the following.
Modify the display on Page A to render an <a name="myRecord" /> for each row of the grid.
On page B, you can redirect back to page A and pass #myRecord at the end of the url, to navigate to the specific entry.

In most browsers, the back button remembers where your were in the page. So a simple javascript:history.go(-1) should do just fine, and anyone who doesn't have javascript enabled can just click the back button.

Related

Confirm Resubmission page on clicking back button

In my page I have a droplist which with OnSelectedIndexChanged event, which initiates a POST request to the server on selection change.
Whenever I navigate away from the page to someother page and try to click the back button in the browser it gives me a "Confirm Resubmission Page" since it has a post data associated for the page.
I cant use redirect to clear the post data since i need the data from the droplist control and other controls to be retained even after the OnSelectedIndexChanged. Is there any solution to come around this issue??
Take a look at this question. May be it can help.
If you can't redirect to self after your post request then you can do it using ajax.

hyperlink and responce.redirect

I am new to asp.net and i need to know
whats the differences between a button with response.redirect behind it
and a hyper link ? they get you both to the page but one is server side while the other is not
is it the only difference
and when it is best to use either one of them
A hyperlink render a link to the given NavigateUrl in the browser. When the user clicks on it, the browser directly goes to the destination.
A button with redirect renders a button which does a postback using javascript. When the user clicks on it, a postback is done to the same page and the browser is instructed to go to another URL using Response.Redirect.
The main difference is that the second solution loads the same page again, while the first solution goes directly to the destination. With a button you can run some code before redirecting, or redirect to a different URL based on the information in the postback. Because it loads the original page before loading the destination page, it is a bit slower.
With a hyperlink, the visitor will see where the hyperlink leads to. With a button you can not see this. A hyperlink is thus better for search engines, because they will follow a hyperlink and will not follow a button.
If you know the URL in advance and you do not want to run extra code when the user clicks on something, use a hyperlink. Else, use a button.
A hyperlink is a link which will redirect you somewhere in the same tab or in a new tab when you click on it.
In case of response.sendredirect() the user's browser is redirected to a link sent by the server depending on your business logic.(the link may belong to some other domain).
hope that helps
Hyperlink control
This is server control use for navigation to another page specified in the NavigateURL property. Hyperlink control doesn’t expose any server side event.
Response.Redirect method
This method is used to navigate to another page from code. You can use this method to navigate from a Linkbutton or ImageButton control.

Automatic page refresh even we navigate to another page

i have a problem in page navigating. please help me to solve out.
in one asp.net page forexample Page1.aspx i have dropdown when we select an item in dropdown that would display in a label. Then we navigate to another page from page1.aspx to page2.aspx by clicking linkbutton in page1.aspx. Again if i come to page1.aspx that previously selected value of dropdown should appear in label.
please help me.
HTTP is a stateless protocol. This means that it'll forget anything that you don't tell it to specifically ask it to.
When going back to Page1.aspx, your program has no idea what was selected before.
In terms of persisting user choices, you should look into storing them in Session ( or alternatively, cookies ) and checking for a pre-existing choice when returning to Page1.aspx.
If you have a saved value for the user at that point, you'll be able to set the correct value during the Page_Load event.
If it is like a wizard, I suggest you use a wizard control in the same page.
here is an example,
https://web.archive.org/web/20211020103244/https://www.4guysfromrolla.com/articles/061406-1.aspx

Previous page should remain in same state when back button of browser is click

I have a page on which there are two drop down lists, based on the selection of those dropdown lists grid view is filled. In grid view there are imagebuttons. When user clicks on any of the image button, he/she is redirected to another page. Now when I click on the back button of the browser, I want page in the same state as it was before redirect. How can I achieve this goal??
use ASP.NET Multiview control instead of separate two pages this will create one page with two views which will effectively retain page state.
Please refer to these articles
http://www.beansoftware.com/ASP.NET-Tutorials/MultiView-Control.aspx
code project multiview

javascript:history.back() on pages and not events

I have an ASPX page that contains a link to "javascript:history.back()"
The problem is that page contains a gridview that changes with events (ex. a column is sorted). Now when I click the link to "javascript:history.back()", it just reverses the event but instead I want to go back to the last page (bypassing all the events).
Is there a simple way to do this?
You'll have to save the referring page's URL when your page first gets called. Then use this URL in your "Back" links.

Resources