我写的第一个ASP.NET"组件"

demo.aspx代码:
<%@ Inherits="FeaturedProduct" %>

  cellspacing="0" bgcolor="<%=BackColor%>">

 


 

Blenders on Sale!


  See our selection of blenders in the
  home appliance deparment.
 


输入颜色:




username:



content:





FeaturedProduct.cs代码:
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 + "','" + content + "')", conConnection);
   conConnection.Open();
   cmdCommand.ExecuteNonQuery();
   conConnection.Close();
 }
}

你可能感兴趣的:(.NET)