Problem with Autopostback

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!
 
J

Jason Turim

Add the following to the page directives, it works for ie5 and above maybe
others
<%@Page ... SmartNavigation="true"%>
 
J

Jos Branders

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
 
J

Jesse

Thank you Natty Gur!
Thank you Jason Turim!
Thank you Jos Branders!

You guys just saved my life!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top