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

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.

Related

Link opens in the same window (has to be a new window)

I have a user control (toolbar). It is located in the master page and most pages in the project use this master page and therefore the toolbar user control. Print button in the toolbar control has to open print page in a new window. It is a hyperlink with target = '_blank'. In most of the pages it opens in a new window and in only one page it opens in the same window (which is wrong). This weird page has the same master page and hyperlink properties is the same during debugging.
Sounds strange, I would check the markup of that specific page where target="_blank" doesn't work and see if it contains any broken markup which could possibly cause that behavior. Maybe the attribute isn't read correctly on that page due to invalid markup somewhere else on that same page.

Force a postback when the back button is pressed

I have a webpage with a combo box on the page which is loaded with it's data on the Page_Load event of the page.
From that page I have a link which opens another page (within the same IE window) which allows the user to add/remove items that should appear in the combo.
The problem I have is when the user adds a new item to the combo I need this item to appear in the list on the parent page. However when I click the back button on the browser the Page_Load event on the parent page doesn't fire and the new item isn't loaded into the combo.
Want is the best way to handle this?
I'm using ASP.NET 4.0 and IE9.
Thanks in advance.
You could use javascript and call window.parent.location.refresh() on your new window to force a reload.
Best regards.

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!

problme with changing control values from a diffrent page

i am using c# aspx , what i'm trying to do is to change a button.visible value from another page.
my page is build from 1 main page and 2 iframes ,the main page uses as a menu, iframe 1 is a login page and iframe 2 is the pages of my site.
on the menu page i have an admin control button which allows me to edit my database , this button visibility is false by default, then , if an administrator is logged in at the login iframe, the button should get visible.
i have tried in so many way to change that button but none worked ,
what i have tried so far:
1) send the button in a session ,recive on other page and change -not working
2) send the whole page and change - not working .
3) make the button public static and change - not working .
i have noticed that even when i change the text on the button on the other page ,on the menu page (the page where the button lays) the button didn't changed it's text.
anothere thing i have noticed is when i press a button on a page , the page is sort of updating (like refreshing but keeps values) , is there a way to make this kind of update manualy?
thanks .
I am assuming from your description that you are trying to change the visibility of the button on the other frame from a post back within the log in frame. The short answer is that this will not work because there is nothing being sent from the server to the client for the other frame.
Your would need to set the visibility of the button in a post back of the page containing the button (which is in the other frame).
It may be better to remove the use of frames and use a master page to provide the log in portion of your page/site as this would allow you to change the visibility of the button in a post back for any page on your site.
For the attempts that you have tried, all three of these should be avoided because the controls are recreated every post back when the page is recreated and will also be disposed every post back in the unload of the page. Since the control and page would be disposed on the first request if you access it on a subsequent call to the server there is no guarantee that the state of the page or control is valid.
For more details on the life cycle of a page, look at the ASP.NET Page Life Cycle Overview:
http://msdn.microsoft.com/en-us/library/ms178472.aspx

Asp.net prevent modal popup to get displayed while clicking on browser back button

GoodEvening Everyone,
I am having one asp.net application which contains many links. some of the link displays modal popup Now if i move to link which nabvigates me and click on browser back button so modal popup gets display which i dont want. i need the previous page should get displayed instead of modal popup if i click on browser back button
for example
i clicked on link1 - navigated to page2
i clicked on link2 - displayed modal popup
i click on link3 - navigated to page3
Now if i click on browser back button so modal popup get displays instead of which i want the page2(previous page before the modal popup ) should get displayed.
So please let me know is this possible and how its possible.
It will be appreciated if some one provide me code to do this...
Let me know in case of more information required
There are several reasons this might be happening.
It might be that you are setting some state flags that persist between pages that influence the modal popups visibility. If you need help with this we will need some more details and preferably code samples.
It might be a browser caching issue. When you hit the back button the browser might be fetching the page from it's cache (not the server) with the popup visible. To test this you could disable the browsers cache and run through your process. If this proves to be the reason you can disable browser caching for your site by adding some meta tags (you'll find the exact tags on Google easily)

Resources