Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnCheckedChange Autopostback question.

Status
Not open for further replies.

columbo2

Technical User
Jul 14, 2006
97
0
0
GB
Hi all,

I have a textbox field in a form that has an associated checkbox.
When this checkbox is checked the field is greyed out and becomes readonly.
Currently I have the onCheckedChange event (with autopostback on)trigger some code that sets the attributes of the textbox to do this.

My problem is that when I click the checkbox the form resets to the top of the page because of the autopostback (I can't get the event to trigger without autopostback which I think is to be expected). I've partially solved this by putting a focus statement in the 'is postback' code. But this always set the focus to a set position that shows the textbox in question in a visible location. Trouble is this can be dissorientating if the user has this textbox in a different place on the screen (due to scroll bar location).

My question is - is there away to get the postback to remember the position of the scroll bar? Or can you trigger the onCheckedChange event code withoput doing a post back.

Thanks in advance
C
 
If you wanted to go to a certain point on the page, based on the scrollbar position, then you will have to tell ASP.NET what this position is. You can then register the client side code to jump to this position onc eth page loads. All of this will need to be done via javascript so I'd ask in that forum.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
I started looking into Javascript and .net (2.0)
and I found this page...


This explained that there was an update to .net 2.0 that sorts this problem.

Just add MaintainScrollPositionOnPostback="true" to the <%@ Page ... %> bit at the top of the HTML page.

Works a treat (but only on asp.net v2.0)

Ta
C
 
It was actually available in version 1.1 under the name of SmartNavigation. However, it was IE only and was notorious for causing problems elsewhere. The MaintainScrollPositionOnPostback method is a better implmentation, however it can still cause some page flickering. Have a play around with it and see what you think slthough a js solution may still work better.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top