The first ASP. NET "component I wrote"

Source: Internet
Author: User
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 );
& Lt; table width = "200" cellpadding = "10"
Cellspacing = "0" bgcolor = "<% = BackColor %>">
<H3> Blenders on Sale! </H3>
See our selection of blenders in
Home appliance deparment.
<Form runat = "server">
Input color:
<Asp: TextBox id = "txtBgcolor" runat = "server"/>
<Asp: Button id = "btnSetBgcolor" onclick = "btnSetBgcolor_click" Text = "Set color" runat = "server"/>
<Asp: TextBox id = "txtUsername" runat = "server"/>
<Asp: TextBox id = "txtContent" runat = "server"/>
<Asp: Button id = "btnSubmit" onclick = "btnSubmit_click" Text = "submit message" runat = "server"/>
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 ();

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.