我正在使用下面的代码在后面的代码中创建一个按钮,并为该按钮创建确认消息框。但它不起作用请帮我创建这个..
Button btn2 = new Button();
btn2.Attributes.Add(
"OnClientClick",
"if (confirm(''Are you sure you want to add this estimate data?')) return;");
if(true)
{
//Do something
}
我正在使用下面的代码在后面的代码中创建一个按钮,并为该按钮创建确认消息框。但它不起作用请帮我创建这个..
Button btn2 = new Button();
btn2.Attributes.Add(
"OnClientClick",
"if (confirm(''Are you sure you want to add this estimate data?')) return;");
if(true)
{
//Do something
}
btn2.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to add this estimate data??')");
您可以使用以下代码:
btn2.Attributes.Add("onclick", "return confirm('Are you sure you want to add this estimate data?');")
您可以将 ajaxcotoroll 工具包引用添加到您的网站,并为每个按钮动态创建确认
Button btn2 = new Button();
btn.ID="buttonID";
ConfirmButtonExtender confirm = new ConfirmButtonExtender();
confirm.TargetControlID = "buttonID";
confirm.ConfirmText="Are you sure you want to add this estimate data??'";
您也可以使用以下代码:-
btn2.Attributes["onClick"] = "return confirm('Are you sure you want to add this estimate data??');"
试试这个鳕鱼:
Button yourbtnid = new Button();
yourbtnid.ID="Button1";
ConfirmButtonExtender conf = new ConfirmButtonExtender();
conf.TargetControlID = "Button1";
conf.ConfirmText="Are you sure you want to add this estimate data??'";
这是使用 Ajaxcontroll 调用..
或者
Button yourbtnid = new Button();
yourbtnid.Attributes.Add(
"OnClientClick",
"return confirm('Are you sure you want to add this estimate data??');");