Changing the master pages' background image?
In our asp.net project, we have a group of forms that have a solid color background and another that needs a background image. We have an if statement on our masterpage that tells us what forms we are on:
If Request.RawUrl.ToLower.Contains("shoes") Th开发者_StackOverflow中文版en
lblSection.Text = "Shoe Store"
ElseIf Request.RawUrl.ToLower.Contains("pants") Then
lblSection.Text = "Pant Store"
End If
How can I change the background image when im in the pants section? Or should I aproach this in a different way?
One option would be to turn the <body>
tag into a server controlled tag.
e.g.
<body id="myBody" runat="server">
Then in your masterpage code, you could add a class
to this depending on the page.
If Request.RawUrl.ToLower.Contains("shoes") Then
lblSection.Text = "Shoe Store"
myBody.Attributes.Add("class", "shoes")
ElseIf Request.RawUrl.ToLower.Contains("pants") Then
lblSection.Text = "Pant Store"
myBody.Attributes.Add("class", "pants")
End If
Then in your css you can have different backgrounds depending on the class name
.shoes{ background: Red; }
.pants{ background: url (imageurl); }
精彩评论