Ask a Question related to ASP.NET General, Design and Development.
-
Jeff Voigt #1
JavaScript / ASP.NET Question (This is a good one)
I just need a few pointers from a few experts to help me finish this up.
In a nutshell I want to return the user to where they left off on a page
througout numerous postbacks. So far, and with little implementation I have
the following:
Public Class BasePage
Inherits System.Web.UI.Page
Private Sub BasePage_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' get out if this is not a post back
If Not Page.IsPostBack Then Return
' get the object name that caused a post back
Dim objectName As String = CType(Request.Form("__EVENTTARGET"),
String)
' get out if the name is nothing
If objectName Is Nothing Then Return
If objectName.Length = 0 Then Return
' register a script to scroll back to this location when returning
RegisterStartupScript("scroll", "<script
language=javascript>document.forms[0]." + objectName +
".scrollIntoView();</script>")
End Sub
End Class
This works great if the user selects a dropdown item when the dropdown has
it's AutoPostback property set to True. Since all of my web pages are
derived from the BasePage this will work beautifully. There is one problem
however in that the __EVENTTARGET will not always refer to the object that
caused the postback. I need this in order for the object.scrollIntoView
java script to fire off.
I've gotten numerous tips as to how I can change it. The one I like best is
to have some kind of hidden fields that track the top/left x/y coordinate of
the window and store that in some hidden fields so on a post back I can
retrieve the values and then call a window.ScrollTo( x,y ) function rather
than relying on the object that caused the post back.
My question now would be, what javascript can I use to constantly store and
x,y coordinate into some hidden fields? I know how to add controls to the
page and get values out. I just need to know if there is a way I can get
the x,y values back from the page on a post back via (storing them in hidden
fields) or something else (if anyone has a better idea).
If this does not make sense, or someone knows a better way to achieve this
please let me know. I would really appreciate the constructive criticism.
Thanks,
- J
Jeff Voigt Guest
-
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you
<RonGrossi382872@yahoo.com> wrote in message news:1114393703.900419.199790@f14g2000cwb.googlegroups.com... This is the most important question of... -
Xcart no good, support no good, need good shopping cart!!!
I need a good quality php shopping cart to port to my site, allowing software downloads and book sales. Integrating ease is really important and... -
John Saunders #2
Re: JavaScript / ASP.NET Question (This is a good one)
Jeff, you might want to make your subject a bit more specific. I almost
didn't read your post until I recognized your name.
Something like "Trying to Replace SmartNavigation With Custom JavaScript"
might be more interesting to more readers.
--
John Saunders
Internet Engineer
[email]john.saunders@surfcontrol.com[/email]
John Saunders Guest
-
Jeff Voigt #3
Re: JavaScript / ASP.NET Question (This is a good one)
I'll do that now :)
"Jeff Voigt" <jeffrey.voigt@djj.state.fl.us> wrote in message
news:#gcnlUeXDHA.1640@TK2MSFTNGP10.phx.gbl...have> I just need a few pointers from a few experts to help me finish this up.
>
> In a nutshell I want to return the user to where they left off on a page
> througout numerous postbacks. So far, and with little implementation Iproblem> the following:
>
> Public Class BasePage
>
> Inherits System.Web.UI.Page
>
>
>
> Private Sub BasePage_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> ' get out if this is not a post back
>
> If Not Page.IsPostBack Then Return
>
> ' get the object name that caused a post back
>
> Dim objectName As String = CType(Request.Form("__EVENTTARGET"),
> String)
>
> ' get out if the name is nothing
>
> If objectName Is Nothing Then Return
>
> If objectName.Length = 0 Then Return
>
> ' register a script to scroll back to this location when returning
>
> RegisterStartupScript("scroll", "<script
> language=javascript>document.forms[0]." + objectName +
> ".scrollIntoView();</script>")
>
> End Sub
>
>
>
> End Class
>
>
> This works great if the user selects a dropdown item when the dropdown has
> it's AutoPostback property set to True. Since all of my web pages are
> derived from the BasePage this will work beautifully. There is oneis> however in that the __EVENTTARGET will not always refer to the object that
> caused the postback. I need this in order for the object.scrollIntoView
> java script to fire off.
>
> I've gotten numerous tips as to how I can change it. The one I like bestof> to have some kind of hidden fields that track the top/left x/y coordinateand> the window and store that in some hidden fields so on a post back I can
> retrieve the values and then call a window.ScrollTo( x,y ) function rather
> than relying on the object that caused the post back.
>
> My question now would be, what javascript can I use to constantly storehidden> x,y coordinate into some hidden fields? I know how to add controls to the
> page and get values out. I just need to know if there is a way I can get
> the x,y values back from the page on a post back via (storing them in> fields) or something else (if anyone has a better idea).
>
> If this does not make sense, or someone knows a better way to achieve this
> please let me know. I would really appreciate the constructive criticism.
>
> Thanks,
> - J
>
>
>
Jeff Voigt Guest



Reply With Quote

