Re: Changing page bgcolor from code (repost)
- From: "GaryDean" <GaryDean@xxxxxxxxxxxxxxxxx>
- Date: Fri, 17 Mar 2006 09:10:09 -0800
Steven,
that was the answer! It was the declaration of bd as an htmlgeneric control
that was missing.
thanks for your help
--
Regards,
Gary Blakely
"Steven Cheng[MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:4lUUNFlRGHA.7400@xxxxxxxxxxxxxxxxxxxxxxxx
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: Steven Cheng[MSFT]
- 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
- Re: Changing page bgcolor from code (repost)
- From: Steven Cheng[MSFT]
- Changing page bgcolor from code (repost)
- Prev by Date: Re: function if javascript enabled, else postback
- Next by Date: Re: Web application setup problem on Win 2003
- Previous by thread: Re: Changing page bgcolor from code (repost)
- Next by thread: Re: Changing page bgcolor from code (repost)
- Index(es):