Re: Changing page bgcolor from code (repost)
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng[MSFT])
- Date: Mon, 13 Mar 2006 03:50:30 GMT
Hi Gary,
I think Juan's suggestion is good. Also, if you do need to programmatically
set the bgcolor for page body in codebehind, we need to mark the body as
"runat=server" and assign an ID, also in codebehind, we need to explicitly
declare a protected control member fields to associate that tag. For
example:
<body id="bd" runat="server" >
===================
public class BgColorPage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txtColor;
protected System.Web.UI.WebControls.Button btnSubmit;
protected HtmlGenericControl bd;
===========================
private void btnSubmit_Click(object sender, System.EventArgs e)
{
System.Drawing.Color bgcolor =
System.Drawing.ColorTranslator.FromHtml(txtColor.Text);
bd.Style["BACKGROUND-COLOR"] =
System.Drawing.ColorTranslator.ToHtml(bgcolor);
}
======================
Hope this helps.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
.
- Follow-Ups:
- Re: Changing page bgcolor from code (repost)
- From: GaryDean
- Re: Changing page bgcolor from code (repost)
- References:
- Changing page bgcolor from code (repost)
- From: GaryDean
- Re: Changing page bgcolor from code (repost)
- From: Juan T. Llibre
- Re: Changing page bgcolor from code (repost)
- From: GaryDean
- Re: Changing page bgcolor from code (repost)
- From: Juan T. Llibre
- Re: Changing page bgcolor from code (repost)
- From: GaryDean
- Re: Changing page bgcolor from code (repost)
- From: Juan T. Llibre
- Changing page bgcolor from code (repost)
- Prev by Date: Re: Asp.net 2.0
- Next by Date: Re: Receiving XML data POSTed to an ASP.Net Page
- Previous by thread: Re: Changing page bgcolor from code (repost)
- Next by thread: Re: Changing page bgcolor from code (repost)
- Index(es):