Force page reload on browser back when the fragment identifier changes - asp.net

Problem:
1.User clicks on this link: default.aspx#id=1.
2.The page loads, the JS from the page gets the fragment identifier (in this case id=1), and then it posts back and loads some content based on that id.
3.User then clicks on the next link: default.aspx#id=2.
4.Same as 2.
5.User clicks the back button in browser.
6.The url changes back to default.aspx#id=1 but the postback is not fired so the new content from #id=1 is not loaded again. (in other words, the page content is not refreshed)
What i need is to somehow reload the page according to #id=1 on back button pressed.
Thanks!

Related

Browser back button does not move to the previous View

I am using views concept in my asp.net form control.my first view consist of a form to capture user details.when user press continue it will move to the second view.
The problem is ,When user press the back button of the browser from the second view it doesn't move the the previous view instead move to the previous page in the browser history.
I wanted to move to the first view with the existing data in the form,when user press the back button of the browser.
You should perform a full page postback I guess, so that at client end your previous view will be saved in browser's history.

loading different pages in Iframe on button click, button is in main page

I have a back and next buttons and Iframe in main page.
On pressing next button next pages (which are forms to take input) are displayed in Iframe from server side.
I want to save data of current page in DB and then load 2nd page in Iframe. On clicking again save data of Page2 in DB and then load 3rd page in Iframe.
Similarly if user clicks back button he should get data of previous page.
Please suggest me how it can be achieved.
Thanks
To chane iframe src just use JS
function changeFrm(NewSrc){
document.getElementById('YOUR IFRAME ID').src=NewSrc;
};
And in your button add onClick="ChangeFrm('NEW SOURCE');"
Good luck!

ASP.NET Event rasied on back button of browser

I have an asp.net page_load event.
When the user clicks the back button of the browser I want to set some values in the page_load event.
The problem is that when I click on the back botton the page is rendered from Cache and the page load event is not fired.
What should I do so that page_load gets fired ...other than forcing the browsers cache to clear ?
If I understand you correctly you have the following situation:
User visits page A.
User clicks a link and visits page B.
User clicks the back button and page A is displayed again. It is displayed from the browser cache, instead of being refetched from the server.
Is that right? In that case you should mark the page as no-cache. With the Response.CacheControl property you can decide what caching options are returned in the http header of the response.
I came up with a solution.
Indeed the back button has nothing to do with the server events...the page is directly renedered from the browser cache.
So what I did was that I ran a script on the page load but not ASP's page load ,rather the javascript page load.
Whenever the back button is clicked the JS page load would be raised.

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.

How to refresh parent page from child page in asp.net 2.0

I have a page showing all products in a gridview.
I have a link in the page clicking on it opens a modal window.
In the modal window there is a form to enter product and save.
When I fill the form and save product I need to make the parent page to be refreshed so that
the new product is listed in the gridview and a message will be shown in a label in the modal window. I need to refresh the product list page without closing the modal window.
How to do it?
Please help.
You can refresh it with the following JavaScript:
window.opener.location.reload(true);
window.opener.location.reload(true);
true makes sure that the page is reloaded from the server instead of the browser's cache.
This will work only if the second page was opened by the first page using javascript and not when you open a link in the first page in a new window - window.opener will be null in the later case. Even in the former case, Firefox will throw a 'permission denied' error if both pages are not from the same domain.

Resources