Demo. aspx code:
<% @ Inherits = "featuredproduct" %>
<Script language = "C #" runat = "server">
Void btnsetbgcolor_click (Object S, eventargs E)
{
Setbackcalor (txtbgcolor. Text );
}
Void btnsubmit_click (Object S, eventargs E)
{
Add (txtusername. Text, txtcontent. Text );
}
</SCRIPT>
& Lt; table width = "200" cellpadding = "10"
Cellspacing = "0" bgcolor = "<% = backcolor %>">
<Tr>
<TD>
<H3> Blenders on sale! </H3>
See our selection of blenders in
Home Appliance deparment.
</TD>
</Tr>
</Table>
<Form runat = "server">
Input color:
<Asp: textbox id = "txtbgcolor" runat = "server"/>
<Asp: button id = "btnsetbgcolor" onclick = "btnsetbgcolor_click" text = "set color" runat = "server"/>
<Br>
Username:
<Asp: textbox id = "txtusername" runat = "server"/>
<Br>
Content:
<Asp: textbox id = "txtcontent" runat = "server"/>
<Br>
<Asp: button id = "btnsubmit" onclick = "btnsubmit_click" text = "Submit message" runat = "server"/>
</Form>
Featuredproduct. CS code:
Using system;
Using system. Data;
Using system. Data. oledb;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Public class featuredproduct: system. Web. UI. Page
{
Public String backcolor = "lightgreen ";
Public void setbackcalor (string Str)
{
Backcolor = STR;
}
Public void add (string username, string content)
{
Oledbconnection conconnection = new oledbconnection ("provider = Microsoft. Jet. oledb.4.0; Data Source =" + server. mappath ("./db1.mdb "));
Oledbcommand into command = new oledbcommand ("insert into guestbook (username, content) values ('" + username + "', '" + content + "')", conconnection );
Conconnection. open ();
Using command. executenonquery ();
Conconnection. Close ();
}
}