[问题] ASP button 删除警示功能修改

楼主: hildaz (小呆熊)   2017-05-24 15:00:35
以下是我ASP的程式码
想请教 如何修正 能在删除前跳出确认删除的视窗 (预防误删)
.aspx
<asp:ImageButton ID="delete" runat="server" Height="40px" ImageAlign="Middle"
ImageUrl="~/images/Delfile.png" ToolTip="删除"
Width="40px"
OnClick="delete_Click" />
.aspx.cs
protected void delete_Click(object sender, ImageClickEventArgs e)
{
Literal myMsg = new Literal();
Literal myMsg1 = new Literal();
Literal myMsg2 = new Literal();
if (TextBox3.Text != "")
{
myMsg1.Text = "<script>alert('规画书确定删除?')</script><br>";
this.Page.Controls.Add(myMsg1);
string strConn =
ConfigurationManager.ConnectionStrings["lseformsConnectionString"].ConnectionString;
System.Data.SqlClient.SqlConnection myConn = new
System.Data.SqlClient.SqlConnection(strConn);
myConn.Open();
string cmdTestText = "DELETE FROM [cancer_plan] WHERE [plan_no] =
@plan_no";
System.Data.SqlClient.SqlCommand myCommand = new
System.Data.SqlClient.SqlCommand(cmdTestText, myConn);
myCommand.Parameters.AddWithValue(@"plan_no", TextBox36.Text);
myCommand.ExecuteNonQuery();
myConn.Close();
myMsg2.Text = "<script>alert('规画书已删除!')</script><br>";
this.Page.Controls.Add(myMsg2);
}
else
{
myMsg.Text = "<script>alert('请输入病历号')</script><br>";
this.Page.Controls.Add(myMsg);
}
}
作者: minejel (梦幻泡影)   2017-05-24 19:52:00
换个思路,不要直接点了画面上显示的按钮就呼叫del
作者: Laluth (阳光)   2017-05-24 22:27:00
关键字 onclientclick confirm
楼主: hildaz (小呆熊)   2017-05-26 04:22:00
感谢 我懂了
作者: alandidi (阿伦弟弟)   2017-05-31 00:42:00
ASP != ASP.NET另外新手的话学MVC吧WebForm不好学习前后端串接

Links booklink

Contact Us: admin [ a t ] ucptt.com