日期:2014-05-18 浏览次数:20450 次
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>无标题页</title> </head> <body> <form id="form1" runat="server"> <div> <div id="div1" runat="server">the masterpage div here</div> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </div> </form> </body> </html>
------解决方案--------------------
竹子给的例子修改的是颜色,你设置图片也行,如
this.Master.TheDiv.Style["background"] = "url(img.jpg)";
------解决方案--------------------
母版页YourMasterPage.master ,中存在:
<div id="div1" runat="server">your masterpage div </div>
------------------------------------------
内容页中修改:
((YourMasterPage)this.Master).div1.Style["background-image"] = "url(your.jpg)";
------解决方案--------------------
//-------剛才忘了設訪問div1的屬性了
母版页YourMasterPage.master ,中存在:
<div id="div1" runat="server"> your masterpage div </div>
-------------------------------------------
母版页YourMasterPage.master.cs ,中存在:
public Control MasterDiv1
{
get { return this.div1; }
}
------------------------------------------
yourpage.aspx.cs内容页中修改:
((YourMasterPage)this.Master).MasterDiv1.Style["background-image"] = "url(your.jpg)";
------解决方案--------------------
楼主如果按竹子的办法是绝对可行的,你不要尝试修改代码,完全COPY竹子的代码先试试再提问你不明白的问题.