开发者

change the master page body color from different pages when they load in vb.net

开发者 https://www.devze.com 2022-12-24 01:23 出处:网络
I have like 10 aspx pages (junior_class_stud开发者_高级运维ents1.aspx-...10.aspx). They all have the same master page in the back (class_students.master). Everytime i load a page i want the master pag

I have like 10 aspx pages (junior_class_stud开发者_高级运维ents1.aspx-...10.aspx). They all have the same master page in the back (class_students.master). Everytime i load a page i want the master page background-color to change, to the one that i can specify per page. so ...students1.aspx then .master ...students2.aspx then .master ...students3.aspx then .master

how can this be achieved?


Keep in mind that content holders can go anywhere in the page. It's possible to do something like this:

<div style="background-color:<asp:ContentPlaceHolder id="divColor" runat="server" />"></div>

And then in your page have this:

<asp:Content ID="divColorContent" ContentPlaceHolderID="divColor" Runat="Server">green</asp:Content>


CSS classes.

You could place a div that fills the body inside on body and contentplaceholder.

Master Page

<body>
<asp:ContentPlaceHolder id="cph" runat="server" />
</body>

That div could have a uniuqe ID per page.

Cntent page

<asp:Content id="cnt" ContentPlaceHolderID="cph">
    <div id="Page1" class="container">
      <!--Page Content-->
    </div>
</asp:Content>

Then CSS could be something like:

div.container
{
    width: 100%;
    height: 100%;
}
div#Page1
{
    background-color: green;
}
div#Page2
{
    background-color: blue;
}
...
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号