Overview
Geeks with blogs have produced a lovely blog that'll show you how to set up your page's script manager to allow your back and forward browser buttons to trigger an event.
It runs through how to enable it using the enableHistory attribute on the script manager and how to wire up the event so that when you use the back buttons it'll fire.
Something that's worth pointing out though, is that you MUST add a history point during a postback event before leaving the page, or your event won't be fired. This may seem obvious, but I didn't realise!
So you'll definitely need a line like this in a postback event:
ScriptManager1.AddHistoryPoint("Key", "Value");
Without that happening at least once before leaving the page, your navigate event won't fire.
My name's Karl Alesbury, and I'm a C# ASP.NET contractor living in Bristol, UK. This blog is an attempt to sort out my coding gremlins or to post solutions on ridding the world of them.
Showing posts with label event. Show all posts
Showing posts with label event. Show all posts
Monday, 4 July 2011
Thursday, 27 September 2007
Premature databinding in a user control
It happens to us all. You go to bind a data repeater to a user control, but it happens far too soon in the event loading process, and you end up with a repeater that doesn't update until you re-refresh the page.
An example of this not working is as follows:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
rptBasket.DataSource = bList
rptBasket.DataBind()
End Sub
The reason this won't work is because the page_load event happens too soon for your repeater to be bound. So use the page_loadcomplete event, right? Wrong. There is no page_loadcomplete event for user controls, so to get your datalist / datarepeater to bind at the right time, you're going to have to use a page_preRender event. It does the same job as the page_loadcomplete event.
An example of this not working is as follows:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
rptBasket.DataSource = bList
rptBasket.DataBind()
End Sub
The reason this won't work is because the page_load event happens too soon for your repeater to be bound. So use the page_loadcomplete event, right? Wrong. There is no page_loadcomplete event for user controls, so to get your datalist / datarepeater to bind at the right time, you're going to have to use a page_preRender event. It does the same job as the page_loadcomplete event.
Labels:
databind,
datalist,
datarepeater,
datasource,
event,
page,
page_loadcomplete,
page_prerender
Subscribe to:
Posts (Atom)