How do i set background for my main page in ASP.NET in web developer ? And then, how do i set color background for the other pages(like page 1 will be gray the page 2 will be blue) ? sorry about my English. Thanks for help and have a nice day.
Asked
Active
Viewed 99 times
-2
-
you need to build different master pages for the set of pages that requires different look and feel – techspider Jan 11 '16 at 18:03
-
Possible duplicate of [Setting background image in asp.net (Master page)](http://stackoverflow.com/questions/13666540/setting-background-image-in-asp-net-master-page) – callmebob Jan 11 '16 at 18:04
-
OK i will do that, just in case, do u know how do i connect a page to a button ? (not linkbutton) – Moshiko Jan 11 '16 at 18:11
-
You can see the following post on how to connect a button to a page: http://stackoverflow.com/questions/16562577/how-can-i-make-a-button-redirect-my-page-to-another-page – Sunil Jan 11 '16 at 19:51
1 Answers
0
To override master page style, you can declare the same CSS rule with !important
in your content/child page.
Example code is as given below. In sample code, the master page has a background color of lightyellow
while a content page using this master page will show up with a background color of lightpink
due to the use of !important
. So, effectively the master page style is being overridden by a content page style.
You can define styles inline as below, or just put them in two separate CSS files - one for master page and the other for content page. Then you need to include the master page CSS file in master page and the content page CSS file in content page.
In Master Page
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
html,body {
background-color:lightyellow;
}
</style>
</head>
In Content Page
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
html,body {
background-color: lightpink !important;
}
</style>
</asp:Content>

Sunil
- 20,653
- 28
- 112
- 197