前台
<table> 表
<tr> 行
<td style="width:189px ; heigh:19px"> 列
<asp: TextBox ID = "txtUserName" runat = "server" onBlur = "send_request('addAdmin');">
</asp:TextBox>
</td>
<td>
<asp: TextBox ID = "txtPassword" runat = "server" onBlur = "send_request('addAdmin');">
</asp:TextBox>
</td>
</tr>
</table>
后台
protected void Button1_Click ( object sender, EventArgs e)
{
if (this.txtUserName.Text !=" ") addAdmin();
}
private void addAdmin ()
{
string userName = this.txtUserName.Text;
string userpwd = this.txtpassword.Text;
string strSql = "INSERT INTO admin ( username , password ) VALUES ( ' " + userName + " ' ,' " + userpwd + " ' ) ";
if ( Convert.ToInt32 ( dbm.executeNonQuery ( strSql ) ) > 0 )
{
this.lblShow.Text = " 好累呀,完成了!" ;
}else{
this.lblShow.Text = " 没完成,呜呜呜!";
}
}
}