Solved

Accessing Site.Master in another page

Posted on 2010-11-17
3
326 Views
Last Modified: 2012-05-10
Good afternoon,
Ive got my <body> tag setup in my site.master file, and I want to be able to set an attribute of the body in a WebForm.

I thought I could just try and set the page in site.master like '<body id="divBody" runat="server">', and then in my PageLoad on the webform I want to set it on do:-
Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        divBody.Attributes.Add("oncontextmenu", "return false"))
    End Sub
End Class

But this doesnt work.

Any ideas how I can set the Body attributes in a different form?

Thank you
0
Comment
Question by:tonelm54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 250 total points
ID: 34155234
In principal you can do:
Dim master As YourMasterPage = CType(Me.Master, YourMasterPage)
master.divBody.Attributes.Add("oncontextmenu", "return false")

Open in new window

Although the body tag is probably protected by default. So, you can either increase its scope to Public, or add a property to the master page to expose it.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34155255
If you wanted to you could add a MasterType directive to your page and then you wouldn't need to do the CType either.
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
ID: 34158900
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question