Follow Fantora on Twitter
Fantora Word of Classified Ads and Community Forum
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: GB

Removing body attribute when page unloads

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!
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

Removing body attribute when page unloads

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

 Related
how to remove 404 error
Linq query in MVC
creating a profile in commerce server 2009 pragmatically
A little confusion on ICallbackEventHandler
using AdRotator control in ASP.Net
Could not load file or assembly 'XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ..
Commerce Server 2009 Starter Site step by step
nopCommerce ASP.NET/C# based opensource shopping cart Installation
MVC Application Structure
'System.Exception' was thrown
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.

Fantora Blog | Discount Shop UK | Discount Shop USA | Discount Shop Canada | Discount Boutique France | Discount Shop Deutschland | Discount Shop Italia | Descuento Shop España

Free Classified ads, Webmaster Forum & Technology Reviews | Fantora Free Classified Ads | Buy & Sell Electronics, Mobile phones & Accessories | fantora Forums Community | Buy & Sell DVD, Games and Consols | Free eBooks & Softwares | SEO & Affiliate Marketing Discussion | Programming Language Forum (.NET, ASP, PHP, SQL) | Free Classified Ads | General Stuff (Movies, Chat, Comics) | Free Online English Movies & Reviews | Free Online Hindi Movies & Reviews | Australia & New Zealand Immigration Forum | Europe immigration forum | Canada Immigration Forum | Ireland Immigration Forum | US Immigration Forum | United Kingdom Immigration Forum

Main Forum RSS : RSS

Powered by: YAF.NET
Copyright © AI Logica All rights reserved.
This page was generated in 0.141 seconds.