Sale on 100% origional Designer Handbags
Welcome Guest Search | Active Topics | Members | Log In | Register

Removing body attribute when page unloads Options
seo_guy
Posted: Thursday, August 27, 2009 9:10:58 AM
Rank: Advanced Member
Groups: Member

Joined: 11/26/2007
Posts: 129
Points: 290
Location: UK
I have a number of pages that all reference a certain master page. In the Page_Load of one of them, I have the following code:

Code:
Dim PageBody As HtmlGenericControl = Me.Master.Body
      If Not PageBody Is Nothing Then PageBody.Attributes.Add("onload", "scrollToPageBottom()")


This works fine as long as I stay on that page. I have several buttons on the page that do various things and then Redirect.Response to this page, and the scrolling works fine.

However, if I click a link on this page that goes to another page that is based on the same master page, my body tag still has the onload attribute set, and so it scrolls to the bottom of the page too, which is not what I want.

How do I detect that the first page mentioned above is being unloaded so that I can remove the onload attribute from the body tag? Or is there another way that I should be accomplishing this?

Thanks!
Sponsor
Posted: Thursday, August 27, 2009 9:10:58 AM
kris_p
Posted: Thursday, August 27, 2009 9:13:22 AM
Rank: Advanced Member
Groups: Member

Joined: 1/7/2008
Posts: 100
Points: 203
Location: Spain
There's another way of approaching this - you want something to happen when the page loads. Use
Code:
ClientScript.RegisterStartupScript() -
much cleaner

Code:
ClientScript.RegisterStartupScript(Me.GetType(), "myScrollScript", "scrollToPageBottom();", true)
;


This will write it to the HTML source and should get executed when the page loads. Won't affect the master page.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by: YAF.NET
Copyright © 2010 HaqTech.com All rights reserved.
This page was generated in 0.171 seconds.