Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 13th, 2005, 01:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default Focus or Scrolling

I have a wizard type page which has 4 or 5 panels that hide/show based on where the user is in the wizard (a panel for each step of the wizard)...several of the panels contain lots of html and form elements, and when the page opens in the browser it scrolls all the way to the bottom. To make things more complicated, it is a framed site (inverted L).

I tried setting the focus to a textbox at the top of the page within the body onload but it seems to not work all the time when the page postsback for some reason(it does work the first time the page loads)...

I also tried using "javascript: scroll(0,0)" in the body onload, and even a "javascript: document.body.scrollTop" in the body onload...all to no avail...

NEED HELP!


-------------------------
Beware of programmers with screwdrivers...
__________________
-------------------------
Beware of programmers with screwdrivers...
 
Old July 14th, 2005, 12:27 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Have you tried using SmartNavigation on the page?

 
Old July 14th, 2005, 07:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default

I am not sure how to "use" it, other than putting it in the Page directive which it already is (smartNavigation="True")...

-------------------------
Beware of programmers with screwdrivers...
 
Old July 14th, 2005, 07:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default

LOL...actually I got it to work by turning OFF smartnavigation...

Quote:
quote:

SmartNavigation seems to be a nice feature - it allows Internet Explorer to handle PostBacks in a very clever way. You don't have to worry about having a long site - it will return to the point where you have been before. Or if you define some events - SmartNavigation will enable you to invoke the handlers without posting the page back to the server.

But: If you are going to program a serious website for users of different browsers (Netscape, Opera, Konqueror or Safari) you need to turn SmartNavigation off, because it simply doesn't work with this kind of browsers.

Another aspect is the following behaviour reported in the newsgroups (and not verified by myself ;): If you would like to put the focus on some objects of your page (i.e. textboxes), you usually use JavaScript:

   Page.RegisterClientScriptBlock("focus", _
     "document.<id-of-your-control>.focus();")

or (VB.NET)

   Page.RegisterClientScriptBlock("focus", _
      "<script language=""JavaScript"">" & _
         "document.<id-of-your-control>.focus();" & _
      "</script> ")

But: Try it with SmartNavigation turned on: It simpy won't work on some systems. The reasons are unknown, but it seems to be, as if IE won't interpret the script correctly.

Sad, isn't it?
from here: http://weblogs.asp.net/ksamaschke/ar...4/27/6085.aspx

-------------------------
Beware of programmers with screwdrivers...
 
Old December 23rd, 2005, 09:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default

How to control scroll when my content (a datalist) is inside a scrollable div?

-------------------------
Beware of programmers with screwdrivers...
 
Old December 23rd, 2005, 10:23 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What do you mean by "control"?

Manipulating the scroll position of a scrollable DIV will be a task for good old DHTML/JavaScript. If you want to maintain the scroll position of a div between postbacks you'll need to write in some handlers for the DIV to store the scroll position to a form value (hidden field) and then after a postback write out javascript to reset the DIV's position to that value.

-Peter
 
Old December 23rd, 2005, 12:21 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default

In my datalist I have Edit commands, and when the user clicks on one of these and the postback occurs it causes the div to scroll back to top.

I tried to do what you're saying with an example from here:http://www.aspnetpro.com/NewsletterA...200309bm_l.asp

by changing the "thebody" to a the id of my scrollable div and this does not work. Any suggestions?



-------------------------
Beware of programmers with screwdrivers...
 
Old December 27th, 2005, 03:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default

OK...I got it after I took a minute to look at that code example...

Here's how to control the scrolling position of a DIV with STYLE=overflow: scroll;

In your code behind:
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RegisterHiddenField("__SCROLLLOC", "0")
        SaveScrollLocation.Append("<script language='javascript'>")
        SaveScrollLocation.Append("function SaveScrollLocation () {")
        SaveScrollLocation.Append("     document.forms[0].__SCROLLLOC.value = divname.scrollTop;")
        SaveScrollLocation.Append("}")
        SaveScrollLocation.Append("divname.onscroll=SaveScrollLocation ;")
        SaveScrollLocation.Append("</script>")
        RegisterStartupScript("saveScroll", SaveScrollLocation.ToString())

        If Not Page.IsPostBack Then

        Else
            SetScrollLocation.Append("<script language='javascript'>")
            SetScrollLocation.Append("function SetScrollLocation () {")
            SetScrollLocation.Append("     divname.scrollTop=" & Request("__SCROLLLOC") & ";")
            SetScrollLocation.Append("}")
            SetScrollLocation.Append("thebody.onload=SetScrollLocation;")
            SetScrollLocation.Append("</script>")
            RegisterStartupScript("setScroll", SetScrollLocation.ToString())
        End If

    End Sub
and in your HTML:

Code:
<html>
<head><title>Example</title>
</head>
<body id="thebody">
<form id="Form1" method="post" runat="server">
<div id="divname" style="overflow: scroll;">
Your content goes here...it will scroll and keep the scroll position on postback...
</div>
</body>
</html>

Thanks Planoie...
-------------------------
Beware of programmers with screwdrivers...





Similar Threads
Thread Thread Starter Forum Replies Last Post
scrolling red_fiesta Classic ASP Professional 5 November 2nd, 2006 12:35 PM
scrolling carro123 Javascript How-To 0 June 6th, 2005 12:29 PM
Scrolling Textbox interrupt Javascript How-To 6 January 11th, 2005 10:29 AM
scrolling smn2 Classic ASP Professional 1 August 28th, 2003 06:57 AM
Scrolling smn2 Classic ASP Basics 0 August 28th, 2003 05:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.