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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript for maintaining vertical position in code behind 1

Status
Not open for further replies.

adddeveloper

Programmer
Dec 16, 2006
43
US
yes, I know I posted this concerning a recent post, but what was with a control I found on the web.

I'm now trying it on my own.

Here's what I have in my HTML:

<a name="#cb1"></a>
<asp:CheckBox id="cb1" runat="server" Text="Don't show me again." AutoPostBack="True">
</asp:CheckBox>

*****************************************************************

For my code behind, I've got the following in the page_load event:

If Page.IsPostBack Then

Response.Write("<script>location.href="" temp_href=""#""<%=Request.Form[""__EVENTTARGET""]%>"";</script>")

End If



...tried this too, and no luck for the page_load event:

***********************************************************************

If Page.IsPostBack Then

Dim strScript As String

strScript = "<script>"

strScript = strScript & "location.href=""#<%=Request.Form[""__EVENTTARGET""]%>"";"

strScript = strScript & "</script>"

Page.RegisterStartupScript("ClientScript", strScript)

End If

Any suggestions are welcome.

Thanks!

 
if you're using Vs 2005, there is a focus property you can use.
 
I have a javascript script sample that acts like SetFocus for .net controls - would you like it? Im sure it will serve your needs.
 
sure...I'm up for anything.

I think since this scenario is really for a cookie in order to now show the user a "new funtionality" page, I'll just go with javascript to set the cookie and not worry about server side code and post-backs.

Thanks!
 
Code:
Response.Write("<script>location.href="" temp_href=""#""<%=Request.Form[""__EVENTTARGET""]%>"";</script>")
Also, never use Response.Write to write anything out to your page. Instead, either use:

1) RegisterStartUpScript method
2) RegisterClientScriptBlock methods
3) A literal/label control and set it's Text property


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Lots of reasons with the main one being where it actually writes it in the markup. In most cases, using Response.Write will render invalid HTML documents.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Smart Navigation is too buggy.. There are too many side effects to using it.
 
Yeah, I tried SmartNavigation....not a good thing. Many issues came up using it. Some of my other Javascript stopped working.

Thanks for the suggestion though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top