[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Accessing Site.Master in another page

Posted on 2010-11-17
3
Medium Priority
?
329 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
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

649 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