.Net问题、、、、在.NET的添加图书的页面中,怎样弹出“添加成功!”的对话框?
在一个页面的Table中有如下的信息:
<asp:Label ID="Label1" runat="server" Text="教材名称:" Width="100px"></asp:Label><asp:TextBox ID="TB_bookname" runat="server"></asp:TextBox><br />
<asp:Label ID="Label2" runat="server" Text="出版日期:" Width="100px"></asp:Label><asp:TextBox ID="TB_date" runat="server"></asp:TextBox><br />
<asp:Label ID="Label3" runat="server" Text="作者:" Width="100px"></asp:Label><asp:TextBox ID="TB_zuozhe" runat="server"></asp:TextBox><br />
<asp:Label ID="Label5" runat="server" Text="价格:" Width="100px"></asp:Label><asp:TextBox ID="TB_price" runat="server"></asp:TextBox><br />
添加信息的按钮是:<asp:Button ID="btnAdd" runat="server" Text="确定添加该教材" onclick="btnAdd_Click" OnClientClick="return confirm('确定要添加吗?');" />
在后台页面中btnAdd_Click事件是:
{
database db = new database();
string zuozhe;
string date;
string bookname;
decimal price;
if (TB_bookname.Text != "")
{
bookname = TB_bookname.Text;
}
else
{
Response.Write("<script lanuage=javascript>alert('没有填写教材名称!');location='javascript:history.go(-1)'</script>");
return;
}
if (TB_date.Text != "")
{
date = TB_date.Text;
}
else
{
Response.Write("<script lanuage=javascript>alert('没有填写教材的出版日期!');location='javascript:history.go(-1)'</script>");
return;
}
if (TB_price.Text != "")
{
price = Convert.ToDecimal(TB_price.Text);
}
else
{
Response.Write("<script language=javascript>alert('没有填写教材的价格!');location='javascript:history.go(-1)'</script>");
return;
}
if (TB_zuozhe.Text != "")
{
zuozhe = TB_zuozhe.Text;
}
else
{
Response.Write("<script language=javascript>alert('没有填写教材的作者!');location='javascript:history.go(-1)'</script>");
return;
}
string sql = "insert into jiaocai" + "(zuozhe,date,bookname,price)" + "values('" + zuozhe + "','" + date + "','" + bookname + "','" + price + "',)";
db.DataCom(sql);
}
请问:想要在运行添加图书时弹出“添加成功!”的对话框,应该再添加一些什么代码呢?
------解决方案--------------------
string sql = "insert into jiaocai" + "(zuozhe,date,bookname,price)" + "values('" + zuozhe + "','" + date + "','" + bookname + "','" + price + "',)";
首先红色部分的逗号是多余的
sql语句没错,db.DataCom(sql);这条语句也执行成功! Response.Write("<script language=javascript>alert('添加成功!')</script>");