asp.net 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>
<table width= "10" cellpadding= "
cellspacing= "0" bgcolor= "<%=BackColor%>" >
<tr>
<td>
We are selection of blenders in the
Home Appliance Deparment.
</td>
</tr>
</table>
<form runat= "Server" >
Enter 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 cmdcommand = new OleDbCommand ("INSERT into Guestbook (username,content) VALUES (' + username +" ', ' "+ conten T + "')", conconnection);
Conconnection.open ();
Cmdcommand.executenonquery ();
Conconnection.close ();
}
}