The first asp.net component I wrote

Source: Internet
Author: User
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 ();
}
}





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.