473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

Nov 17 '05 #1
2 1229
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
jo***********@surfcontrol.com
Nov 17 '05 #2
I'll do that now :)

"Jeff Voigt" <je***********@djj.state.fl.us> wrote in message
news:#g**************@TK2MSFTNGP10.phx.gbl...
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

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
11
by: =?iso-8859-1?q?Martin_M=FCcke?= | last post by:
Hi, I am looking for a good javascript obfuscator - I found several on the web, but I am looking for one that can also handle javascript in jsp, html and java files - so I need a javascript...
76
by: lorlarz | last post by:
Crockford's JavaScript, The Good Parts (a book review). This shall perhaps be the world's shortest book review (for one of the world's shortests books). I like Douglas Crockford (because I am a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.