Problem with Autopostback

  • Thread starter Thread starter Jesse
  • Start date Start date
J

Jesse

I have a relatively long page with a number of webcontrols with
"autopostback" set to true. The contents/items/datasources of the subsequent
webcontrols are dynamically populated depending on the selection of previous
webcontrols' selected item.

My question is : everytime the user selects an option from a webcontrol, due
to the autopostback being turned on, the page refreshes itself to populate
the subsequent controls. The problem I have is that when it refreshes, it
always ends up showing the top of my very long page.

Are there anyway i could somehow return to the location of the last selected
control that triggered that event or the next control after that? Anchors
does not work here, does it? If not, then how do i do it?

Please help!
 
Add the following to the page directives, it works for ie5 and above maybe
others
<%@Page ... SmartNavigation="true"%>
 
Jesse said:
I have a relatively long page with a number of webcontrols with
"autopostback" set to true. The contents/items/datasources of the subsequent
webcontrols are dynamically populated depending on the selection of previous
webcontrols' selected item.

My question is : everytime the user selects an option from a webcontrol, due
to the autopostback being turned on, the page refreshes itself to populate
the subsequent controls. The problem I have is that when it refreshes, it
always ends up showing the top of my very long page.

Are there anyway i could somehow return to the location of the last selected
control that triggered that event or the next control after that? Anchors
does not work here, does it? If not, then how do i do it?

To make a workaround in other browsers apart from IE5 and 6, you could
think of inserting a numbered bookmark with each control:
<a name="bookmark01">&nbsp</a>

Then, on postback, insert a script to go to the right bookmark:
Sub InsertScriptBlock()
Dim jScript As new System.Text.StringBuilder()
jScript.Append("<script language='JavaScript'>")
jScript.Append("location.href='#bookmark01';")
jScript.Append("</scr" & "ipt>")
Me.RegisterClientScriptBlock("Bookmark", jScript.ToString())
End Sub
 
Thank you Natty Gur!
Thank you Jason Turim!
Thank you Jos Branders!

You guys just saved my life!!!
 
Back
Top