James Campbell
James Campbell

Reputation: 5087

How to resize master page div from content page

How would I go about resizing a div from a page to it's master page?

Making the div a server side control doesn't seem to be an option as all applied css breaks from the name change and I cannot modify the css file.

I have tried the solution below from Hunter using the MasterType and then creating a property in my base master page, but my content page does not see the public property.

I have three files involved listed in their hierarchal structure.

1) Base master page where div resides
2) Master page for section of site
3) Content page for which I need to change the div in #1

Upvotes: 1

Views: 3855

Answers (2)

Ender
Ender

Reputation: 15221

Perhaps there is an easier (though admittedly less clean) method of doing this. Give your div a class which is not defined in your stylesheets, and then put a style tag on your page, like so:

<style type="text/css">.myDivClass { width: 42px; } //or whatever width you like</style>

Of course, this requires that you have a header placeholder in your MasterPage.

Upvotes: -1

hunter
hunter

Reputation: 63522

you could trying setting the pages MasterType, which will let you manipulate members on the MasterPage directly from the page

So in your master page you could add Property like this:

public int DivWidth { get; set; }

Then on your page you can add this to the .aspx content below the <@ Page line:

<%@ MasterType TypeName="Name.Space.Master" %>

which is the namespace and class of your Master page.

Then on the pages code behind you should be able to set that Property like so:

Page.Master.DivWidth = 100;

More on the MasterType directive: http://msdn.microsoft.com/en-us/library/ms228274(v=VS.90).aspx

Upvotes: 3

Related Questions