Refresh content page when master page is updated - asp.net

My site uses a Calendar control to determine what date to get data for.
Because this calendar should be visible on every page, I've placed it on my MasterPage.
If the date on the calendar is changed, it should cause the data shown in the Content page to be updated with data specific for the new date. Essentially, it should cause the page to be reloaded.
Because the calendar is on the MasterPage, that's where I'm putting the SelectionChanged event handler, but I'm not sure how to "reload" the content page from here. All I can think of is a Response.Redirect, and I'm not sure if that's the best option.
Can anyone give me any suggestions?

Decided I'd simplify this and make the master page element a hyperlink that redirected to a page that had the calender on it and "Save" button on it.
I found this much easier to manage...
The calendar loads with today's date, allows the user to select another date and the save button writes the new selected date into a session variable read for the data that is to appear on all the content pages.
It means the user has to specially go away from what he/she is currently doing in order to set the date, but I actually prefer it this way.

Related

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.

persisting links on an asp.net page - is this a job for viewstate?

I've got a master page with a section for subnavigation links on it:
<div id="sub_nav" runat="server"></div>
I programatically populate this with Hyperlinks when my main asp:Menu data is bound depending on the address of the page I'm on.
This works fine and all my correct submenu stuff shows up on each page. The problem is that when one of these pages does a postback, I lose all the links that were in my sub_nav div.
Now, I could just populate the div with links every time regardless of whether the master page load is a postback or not, but I figured there is a better way of doing this. I was thinking enabling the viewstate on the div and links inside it might persist them through postbacks, but apparently that is not how viewstate works.
What is the correct way of doing this?
Viewstate only stores the current state of a control and not the controls by themselves. If you are dynamically adding controls make sure to add them on page init method irrespective of postback
This MSDN sample should help you.
According to the excellent article TRULY Understanding ViewState, that's not really the purpose of ViewState. Furthermore, ViewState costs additional bandwidth so in general we want to avoid it if possible. It sounds like this data should be "cheap" to obtain (cacheable or whatnot), so I'd definitely populate it on every request and disable ViewState on those controls.
To understand the main purpose of ViewState consider a page with two buttons, btnA and btnB and two labels lblA and lblB.
When the user clicks btnA , the page posts back and sets lblA to "You clicked A!".
When the user clicks btnB, the page posts back and sets lblB to "You clicked B!".
With ViewState, the page remembers that lblA.Text was set to "You clicked A!" previously and restores that value. Without ViewState, if the user clicked A and then B, the page would only display "You clicked B!" because there's nothing to store the previous value of lblA.

in ajaxified page back button is not working

in my ajaxified page i have used several user control shifting from one user control to anothe r and then pressing the back button takes me to first page instead of previously filtered page
how to solve this
all this filters are linkbuttons i am also using listview these filters are actually filtering the content of this listview
You may take a look at the jquery history plugin. If you are using UpdatePanel to perform the AJAX requests you might find this article helpful as well as this video.

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