?
Solved

Accessing Site.Master in another page

Posted on 2010-11-17
3
Medium Priority
?
328 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 1000 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 1000 total points
ID: 34158900
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 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