点击按钮弹出  确认 取消对话框. 确认就执行,取消就是不执行.
我要写在xxxx.aspx.vb上的代码
不要aspx上的.
另外,出现对话框后的页面的字体怎么自动改变了呢?

解决方案 »

  1.   

    this.Button1.Attributes.Add("onclick","javascript:return confirm('要提交吗?');");
    字体改变不要,除非自己用div模拟。
      

  2.   

    btn1.Attributes.Add("onclick", "javascript:return confirm('yes or no');");
      

  3.   

    如果你想在xxxx.aspx.vb中分析判断后再弹出对话框,无法实现!
    否则可以写在pageload里
    private void page_load()
    {
    this.Button1.Attributes.Add("onclick","javascript:return   confirm('要提交吗?');"); 
    }
      

  4.   

    顶上去吧
    this.Button1.Attributes.Add("onclick","javascript:return   confirm('要提交吗?');"); 
      

  5.   

     ((LinkButton)(e.Row.Cells[?].Controls[?])).Attributes.Add("onclick", "return confirm('要提交吗?')");
      

  6.   

    五楼是对的,
    但是应该加一个条件if(!Ispostback)
    {
    this.Button1.Attributes.Add("onclick","javascript:return       confirm('要提交吗?');");  
    }
      

  7.   

     Delete.Attributes.Add("onclick", "return confirm('确定要将文章删除,这将不能恢复?')");
      

  8.   

    各位哥哥姐姐们,this.Button1.Attributes.Add("onclick","javascript:return               confirm('要提交吗?');");     
    这个解已经有了,谢谢各位.
    现在的问题是为什么第一次点击按钮不弹出对话框,第2次才弹出?
      

  9.   

    在PreRender事件中加this.Button1.Attributes.Add("onclick","javascript:return                               confirm('要提交吗?');");           
      

  10.   

    <input onclick="return confirm('are your sure?');"/>
      

  11.   

    楼主字体之所以改变,是因为使用了Response.Write()把js输出了吧,这样破坏了页面的结构导致CSS失效。
      

  12.   

    1楼:
    this.Button1.Attributes.Add("onclick","javascript:return   confirm('要提交吗?');"); 
    字体改变不要,除非自己用div模拟。楼上:
    楼主字体之所以改变,是因为使用了Response.Write()把js输出了吧,这样破坏了页面的结构导致CSS失效。--------------------------
    up
      

  13.   

    this.Button1.Attributes.Add("onclick","javascript:return       confirm('要提交吗?');");   
      

  14.   

    The easiest way is to just add this to the button which will stop the server-side event from being called if the user chooses Cancel:
    Button1.Attributes.Add("onclick", "if ( confirm('Are you sure?') != true ) return false;")Another way, if you have to have the results server-side is:
    In the aspx file:
     <input type="hidden" id="Hidden1" name="Hidden1" runat="server">
    That adds this to the CodeBehind:
     Protected WithEvents Hidden1 As System.Web.UI.HtmlControls.HtmlInputHiddenThen add to the Page_Load event handler:Dim scriptString As String = "<script language=JavaScript> " + Environment.NewLine
    ' Store the confirm's return in the hidden control...
    scriptString += "document.getElementById('" + Hidden1.ClientID + "').value = " + Environment.NewLine
    scriptString += " confirm('Are you sure?'');" + Environment.NewLine
    ' Do a new PostBack...
    scriptString += GetPostBackEventReference(Hidden1, String.Empty) + ";" + Environment.NewLine
    scriptString += "</script>"RegisterStartupScript("ConfirmScript", scriptString)If IsPostBack AndAlso Request("__EVENTTARGET") = "Hidden1" Then
         If Hidden1.Value = "true" Then
              ' User answered OK
         Else
              ' User answered Cancel
         End If
    End If
    Hidden1.Value = String.Empty