problme with changing control values from a diffrent page - asp.net

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

Related

Give control back to the first page after Server.execute()

I have a registration.aspx page. After entering all the information, user has to press the register button, which will add it to the DB. After that it shows a message that says "registered successfully".
To do this I created a separate web form to display the success message. So after the process happens successfully I simply call this separate .aspx file by using
Server.Execute("~/AlertMsg/ValidationMsg.aspx");
So everything is fine. The user can see a beautiful box at the top of the page. But the problem is after executing the 2nd page (ValidationMsg.aspx) inside the 1st page, control goes to the 2nd page. Because of that, if I click a dropdown or button in my 1st page (that has autopostback enabled), my page only shows the validation window.
What I wanted to do is to take control back to the 1st page after executing the server.execute. What should I do? Is there any good way to do this? I don't want to use JavaScript.
Below green color box is my separate web form.
Image 1:
Image 2 (after registering):

listview itemcommand not firing after back button

I have page that uses a multiview. Each view contains a separate user control. One of these user controls has a list view with an image button that causes the loading of a different view in the multiview. All is fine up until this point. When the user hits the back button, they are taken back to the user control that contains the list view. The user then clicks on another image button to view different data and it returns to the detail user control using the same data as before. While debugging, I have seen that the item command event does not fire after hitting the back button.
I have tried replacing the multiview and putting each user control into separate panels. This did not change the outcome at all.
I have tried setting a cookie that expires 5 seconds after page load. When the user continues to the next page, then clicks back (and it has been longer than 5 seconds), I force the form to submit again. This loads the next control again instead of reloading the page.
I have tried setting the cacheability to no cache. This causes a "page expired" message and the user has to refresh the page. This is ugly for the user and definitely takes away from the user experience.
I am looking for the cleanest way for a user to click back and have the page reloaded so that the item command event fires correctly again.
The reason is that Back doesn't affect the Page Life Cycle. It's definitely because the page is cached and cached page doesn't execute on server. You can try this code to get rid of this issue.
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
It took a lot of research to find this answer, so hopefully other people stumble upon this question and find my answer. I was astonished that I was actually able to find this. Ok, enough gloating.
Because the page does not postback when the user clicks the back button, the events are not fired correctly causing problems with the next page. What has to happen is you need to be able to handle the browser's navigation buttons (i.e. back and forward). To do this you have to set EnableHistory to true within the script manager and handle the Navigate event from the script manager. You can then reload the controls using the information you save in the state object.
I used these articles from Dino Esposito on DotNetSlackers.com as a reference. Server Side History Management and Client Side History Management

which Asp.net page properties to work with ...? please find details below

I am having an application where I am displaying an modal dialog if the page is getting loaded for first time but when i navigate to any other page within the web site then also the modal dialog get displayed what i need is modal diaolg should get displayed only for first time and not while navigating within web site. "Just one time display of modal dialog to user not again and again if user navigates within website"
The modal dialog is coming from javascript and i am using asp.net 3.5
and not using ispostback any suggestion or condition other than ispostback is needed
Is there any property of page which is true/false for first time the page is loaded and gets false/true when the user navigates to other page within website...?
any way/logic to do it ...?
Thanks,
Nilesh
There is no property that will allow you to determine whether the pageis accessed for the first time or not. One way to handle this is to use a Session variable where you could store whether the user has already visited the first page.

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