我把 button.attributes.add("onclick","if(confirm('are you sure...?')){return true;}else{return false;}") 写在后置代码的单击事件里,为什么总是第一次点击没反应,要点第二次才会弹出对话框啊
test.vb Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Button1.Attributes.Add("onclick", "if(confirm('are you sure...?')){return true;}else{return false;}") End Sub 为什么,总是第一次没反应,要第二次单击才弹出对话框
怎么回事,我怎么写都是不能弹出来呢?都试过了,如下所示: Public Sub btDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btDel.Click 'btDel.Attributes.Add("onclick", "javascript: return confirm('确定要删除此项吗?');") btDel.Attributes.Add("onclick", "if(confirm('are you sure...?')){return true;}else{return false;}") end Sub
如果是win 就很简单。
如果是web就最好在html文件里写一个javascript函数来实现,很简单的,而且用起来也很方便,在CS文件里直接判断就可以了
<!--
function confirm_del()
{
if(window.confirm('are you sure want to delete this record?'))
{return true;}
else
{return false;}
}
</SCRIPT>
javascript函数这样写没错吧
在vb里面:
btDel.Attributes.Add("onclick", "JavaScript: return confirm_del();")
{
e.Item.Cells[4].Attributes.Add("onclick","javascript: return confirm('确定要删除此项吗?');");
}
我这个是在DATEGRID中删除的时候的提示确认
button.attributes.add("onclick","if(confirm('are you sure...?')){return true;}else{return false;}")
写在后置代码的单击事件里,为什么总是第一次点击没反应,要点第二次才会弹出对话框啊
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Attributes.Add("onclick", "if(confirm('are you sure...?')){return true;}else{return false;}") End Sub
为什么,总是第一次没反应,要第二次单击才弹出对话框
Public Sub btDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btDel.Click
'btDel.Attributes.Add("onclick", "javascript: return confirm('确定要删除此项吗?');")
btDel.Attributes.Add("onclick", "if(confirm('are you sure...?')){return true;}else{return false;}")
end Sub