怎么成功后添加后跳出对话框?

来源:百度知道 编辑:UC知道 时间:2024/05/10 09:31:20
protected void btn_Edit_Click(object sender, EventArgs e)
{
try
{
T_News model = new T_News();
model.News_Title_S = txt_News_Title_S.Text;
model.News_Content_S = txt_News_Content_S.Text;
model.News_From_S = txt_News_From_S.Text;
model.News_Category_ID_N =Convert.ToInt32( txt_News_Category_N.Text);
model.News_Author_S = txt_News_Author_S.Text;
NewsBLL.Instance.AddNews(model);
Response.Write("<script>alert('添加成功')</script>");
}
catch(Exception x)
{
Response.Write("<script>alert('添加失败')</script>");
}
}
使成功添加到数据库里后才跳成功 写那一运行就跳 用onclikc的话点完就跳成功,怎么成功后才跳出对话框
怎么判断 添加后才跳出对话框

你这还要判断吗 你有try 就没必要再判断了 应为你添加不成功的话

它就跳到 catch 也就是显示 添加失败 你调试看一下吧 肯定是添加成功后才显示对话框的

通过方法返回值判断