473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Web Form Background color


Is there a way to change the background color of a web
form on the server before it is posted? In the pageLoad
event I can do it to server controls by adding an
attribute, however, how do I do the same for the page's
background color?

Should be simple I think?

Jerry J
Nov 17 '05 #1
6 4978
You need to use the HtmlGenericControl. The code below is a code-behind version
of an example near the bottom of this page:

http://msdn.microsoft.com/library/de...riccontrol.asp

Does this help?

Ken
MVP [ASP.NET]

Public Class bdycolour
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents ColorSelect As System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents Submit1 As System.Web.UI.HtmlControls.HtmlInputButton

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Public Sub SubmitBtn_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Submit1.ServerClick
Dim Body As New HtmlGenericControl
Body = Page.Controls(1)
Body.Attributes("bgcolor") = ColorSelect.Value
End Sub
End Class


<%@ Page Language="vb" AutoEventWireup="false" Codebehind="bdycolour.aspx.vb"
Inherits="p733workev.bdycolour"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>bdycolour</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body id="Body" runat="server">
<h3>Updating Styles with the HtmlGenericControl</h3>
<form runat="server" id="Form1">
<p>
Select a background color for the page:
<p>
<select id="ColorSelect" runat="server" name="ColorSelect">
<option selected>White</option>
<option>Wheat</option>
<option>Gainsboro</option>
<option>LemonChiffon</option>
</select>
<input type="submit" runat="server" value="Apply"
onserverclick="SubmitBtn_Click" id="Submit1"
name="Submit1">
</form>
</P>
</body>
</html>
--
Microsoft MVPs have a question for *you*: Are you patched against the Worm?
http://www.microsoft.com/security/se...s/ms03-026.asp

"Jerry J" <Ja*************@NospamIntegrisolve.com> wrote in message
news:01****************************@phx.gbl...

Is there a way to change the background color of a web
form on the server before it is posted? In the pageLoad
event I can do it to server controls by adding an
attribute, however, how do I do the same for the page's
background color?

Should be simple I think?

Jerry J
Nov 17 '05 #2
Don't forget runat="server" in the body tag
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
You need to use the HtmlGenericControl. The code below is a code-behind version of an example near the bottom of this page:

http://msdn.microsoft.com/library/de...riccontrol.asp
Does this help?

Ken
MVP [ASP.NET]

Public Class bdycolour
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents ColorSelect As System.Web.UI.HtmlControls.HtmlSelect Protected WithEvents Submit1 As System.Web.UI.HtmlControls.HtmlInputButton
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Public Sub SubmitBtn_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Submit1.ServerClick
Dim Body As New HtmlGenericControl
Body = Page.Controls(1)
Body.Attributes("bgcolor") = ColorSelect.Value
End Sub
End Class


<%@ Page Language="vb" AutoEventWireup="false" Codebehind="bdycolour.aspx.vb" Inherits="p733workev.bdycolour"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>bdycolour</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body id="Body" runat="server">
<h3>Updating Styles with the HtmlGenericControl</h3>
<form runat="server" id="Form1">
<p>
Select a background color for the page:
<p>
<select id="ColorSelect" runat="server" name="ColorSelect">
<option selected>White</option>
<option>Wheat</option>
<option>Gainsboro</option>
<option>LemonChiffon</option>
</select>
<input type="submit" runat="server" value="Apply"
onserverclick="SubmitBtn_Click" id="Submit1"
name="Submit1">
</form>
</P>
</body>
</html>
--
Microsoft MVPs have a question for *you*: Are you patched against the Worm? http://www.microsoft.com/security/se...s/ms03-026.asp

"Jerry J" <Ja*************@NospamIntegrisolve.com> wrote in message
news:01****************************@phx.gbl...

Is there a way to change the background color of a web
form on the server before it is posted? In the pageLoad
event I can do it to server controls by adding an
attribute, however, how do I do the same for the page's
background color?

Should be simple I think?

Jerry J

Nov 17 '05 #3
I think it is there.

--
Microsoft MVPs have a question for *you*: Are you patched against the Worm?
http://www.microsoft.com/security/se...s/ms03-026.asp

"MS News (MS ILM)" <sq**********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Don't forget runat="server" in the body tag
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
You need to use the HtmlGenericControl. The code below is a code-behind version of an example near the bottom of this page:

http://msdn.microsoft.com/library/de...riccontrol.asp
Does this help?

Ken
MVP [ASP.NET]

Public Class bdycolour
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents ColorSelect As System.Web.UI.HtmlControls.HtmlSelect Protected WithEvents Submit1 As System.Web.UI.HtmlControls.HtmlInputButton
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Public Sub SubmitBtn_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Submit1.ServerClick
Dim Body As New HtmlGenericControl
Body = Page.Controls(1)
Body.Attributes("bgcolor") = ColorSelect.Value
End Sub
End Class


<%@ Page Language="vb" AutoEventWireup="false" Codebehind="bdycolour.aspx.vb" Inherits="p733workev.bdycolour"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>bdycolour</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body id="Body" runat="server">
<h3>Updating Styles with the HtmlGenericControl</h3>
<form runat="server" id="Form1">
<p>
Select a background color for the page:
<p>
<select id="ColorSelect" runat="server" name="ColorSelect">
<option selected>White</option>
<option>Wheat</option>
<option>Gainsboro</option>
<option>LemonChiffon</option>
</select>
<input type="submit" runat="server" value="Apply"
onserverclick="SubmitBtn_Click" id="Submit1"
name="Submit1">
</form>
</P>
</body>
</html>
--
Microsoft MVPs have a question for *you*: Are you patched against the Worm? http://www.microsoft.com/security/se...s/ms03-026.asp

"Jerry J" <Ja*************@NospamIntegrisolve.com> wrote in message
news:01****************************@phx.gbl...

Is there a way to change the background color of a web
form on the server before it is posted? In the pageLoad
event I can do it to server controls by adding an
attribute, however, how do I do the same for the page's
background color?

Should be simple I think?

Jerry J


Nov 17 '05 #4
Yes it is, I did not copy your code and when I tried it I forgot the
runat="server" myself
so I am just trying to save someone some time in case if they don't copy
your code.

Thank you.

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:eP**************@TK2MSFTNGP10.phx.gbl...
I think it is there.

--
Microsoft MVPs have a question for *you*: Are you patched against the Worm? http://www.microsoft.com/security/se...s/ms03-026.asp

"MS News (MS ILM)" <sq**********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Don't forget runat="server" in the body tag
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
You need to use the HtmlGenericControl. The code below is a code-behind

version
of an example near the bottom of this page:

http://msdn.microsoft.com/library/de...riccontrol.asp

Does this help?

Ken
MVP [ASP.NET]

Public Class bdycolour
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents ColorSelect As

System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents Submit1 As

System.Web.UI.HtmlControls.HtmlInputButton

'NOTE: The following placeholder declaration is required by the Web

Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Public Sub SubmitBtn_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Submit1.ServerClick
Dim Body As New HtmlGenericControl
Body = Page.Controls(1)
Body.Attributes("bgcolor") = ColorSelect.Value
End Sub
End Class


<%@ Page Language="vb" AutoEventWireup="false"

Codebehind="bdycolour.aspx.vb"
Inherits="p733workev.bdycolour"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>bdycolour</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body id="Body" runat="server">
<h3>Updating Styles with the HtmlGenericControl</h3>
<form runat="server" id="Form1">
<p>
Select a background color for the page:
<p>
<select id="ColorSelect" runat="server" name="ColorSelect">
<option selected>White</option>
<option>Wheat</option>
<option>Gainsboro</option>
<option>LemonChiffon</option>
</select>
<input type="submit" runat="server" value="Apply"
onserverclick="SubmitBtn_Click" id="Submit1"
name="Submit1">
</form>
</P>
</body>
</html>
--
Microsoft MVPs have a question for *you*: Are you patched against the

Worm?
http://www.microsoft.com/security/se...s/ms03-026.asp

"Jerry J" <Ja*************@NospamIntegrisolve.com> wrote in message
news:01****************************@phx.gbl...

Is there a way to change the background color of a web
form on the server before it is posted? In the pageLoad
event I can do it to server controls by adding an
attribute, however, how do I do the same for the page's
background color?

Should be simple I think?

Jerry J


Nov 17 '05 #5
Okay. I understand now what you meant. Thanks.

--
Microsoft MVPs have a question for *you*: Are you patched against the Worm?
http://www.microsoft.com/security/se...s/ms03-026.asp

"MS News (MS ILM)" <sq**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Yes it is, I did not copy your code and when I tried it I forgot the
runat="server" myself
so I am just trying to save someone some time in case if they don't copy
your code.

Thank you.

Nov 17 '05 #6

Ken,

Thanks for the information. I don't understand how it
works, but I am going to give it a try.

Thanks

Jerry J

-----Original Message-----
You need to use the HtmlGenericControl. The code below is a code-behind versionof an example near the bottom of this page:

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/cpgenref/html/cpconhtmlgenericcontrol.asp
Does this help?

Ken
MVP [ASP.NET]

Public Class bdycolour
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents ColorSelect As System.Web.UI.HtmlControls.HtmlSelect Protected WithEvents Submit1 As System.Web.UI.HtmlControls.HtmlInputButton
'NOTE: The following placeholder declaration is required by the Web FormDesigner.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Public Sub SubmitBtn_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Submit1.ServerClick
Dim Body As New HtmlGenericControl
Body = Page.Controls(1)
Body.Attributes("bgcolor") = ColorSelect.Value
End Sub
End Class


<%@ Page Language="vb" AutoEventWireup="false" Codebehind="bdycolour.aspx.vb"Inherits="p733workev.bdycolour"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
<head>
<title>bdycolour</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body id="Body" runat="server">
<h3>Updating Styles with the HtmlGenericControl</h3>
<form runat="server" id="Form1">
<p>
Select a background color for the page:
<p>
<select id="ColorSelect" runat="server" name="ColorSelect"> <option selected>White</option>
<option>Wheat</option>
<option>Gainsboro</option>
<option>LemonChiffon</option>
</select>
<input type="submit" runat="server" value="Apply"
onserverclick="SubmitBtn_Click" id="Submit1"
name="Submit1">
</form>
</P>
</body>
</html>
--
Microsoft MVPs have a question for *you*: Are you patched against the Worm?http://www.microsoft.com/security/se...ulletins/ms03- 026.asp
"Jerry J" <Ja*************@NospamIntegrisolve.com> wrote in messagenews:01****************************@phx.gbl...

Is there a way to change the background color of a web
form on the server before it is posted? In the pageLoad
event I can do it to server controls by adding an
attribute, however, how do I do the same for the page's
background color?

Should be simple I think?

Jerry J
.

Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mattaku | last post by:
I have a background image for my form that has an alpha channel (PNG or GIF). I would like my form to become semi-transparent and partially show the desktop. I can figure out how to set the form's...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
1
by: news.wanadoo.nl | last post by:
Hi, I have found whit google this form in this group. But i'n not good in javascript :(. I try and error normal but i only error now :P Whit i now want to now how can i get access to the vars...
2
by: alwaysintune | last post by:
I'm using the McFedries email form, and I can't seem to get an upload form to work. Instead of it saving to my server, I want it to send the information and the picture to my email. Here is the...
5
by: jsavagedesign | last post by:
I am trying to send and email from a form using php. I got that to work. The problem is that when I receve the email it is a text version with all the html tags showing. looks like this:...
1
by: morangi | last post by:
<?php session_start(); error_reporting(E_ERROR && ~E_NOTICE && ~E_WARNING); ob_start(); $link = mysql_connect('localhost', 'root', 'test'); if (!$link) { die('Could not connect: ' ....
2
by: ravisuguna | last post by:
Hi, I have a php page which has some checkboxes ,textfields and values.If I select a checkbox ,a particular value will be displayed in a textfield.I have a "go"button in the same page.I want the...
6
by: shapper | last post by:
Hello, I am creating a form that includes a few JQuery scripts and TinyMCE Editor: http://www.27lamps.com/Beta/Form/Form.html I am having a few problems with my CSS: 1. Restyling the Select
4
by: AAaron123 | last post by:
<body runat="server" id="MainBody"> <form id="form1" runat="server" style="background-color:green; width: 100%; height: 100%"> <br /> Table1" runat="server" Style="background-color:Yellow;...
13
by: Andrew Falanga | last post by:
HI, Just a warning, I'm a javascript neophyte. I'm writing a function to validate the contents of a form on a web page I'm developing. Since I'm a neophyte, this function is quite simple at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.