tags:

views:

29

answers:

4

How do I set the scrollbars in an ASP.net page dynamically? When a user comes to certain pages on my site I would like the page to be scrolled down about halfway. Is there a way to do this without using Javascript?

+4  A: 

One standard HTML option is to set a target <a name="foo"></a> on your page. Links to the page would need to be /yourpage.aspx#foo, but that would cause the browser to scroll to the target.

Anthony Pegram
I'm using this approach
John H.
A: 

asp.net is a server side technology so it is not possible to manage the scroll position without using javascript. At least I have not seen it done.

spinon
The method @Anthony mentioned is a possibility but it really doesn't have anything to do with asp.net
spinon
+1  A: 

Sounds like you're looking for an anchor tag. You specify the URL as www.site.com/page.aspx#middle

Then in your page, you put the tag where you want them to scroll to

<a name="middle" /> 

http://www.w3schools.com/tags/tag_a.asp

Tim Coker
Attribute should be name, not id.
Adrian Godong
Both work, but yes, according to the standard, name is the correct tag. Web standards are such a slippery slope because of of the browser implementations' inconsistencies.
Tim Coker
A: 

Something you might be interested in that I've used successfully on projects before is the smartScroller. You can place this control on a web page and the web page will automatically remember the scroll position between postbacks and scroll there. Check it out: http://www.4guysfromrolla.com/articles/111704-1.aspx

It does use javascript though. Any reason in particular you don't want to use javascript?

icemanind