在C#中,点击<asp:button/>控件弹出对话框应该怎么做?

解决方案 »

  1.   

    onclick事件
    {
    Response.Write("<script>alert('sdfsdf');</script>");
    }
      

  2.   

    这个方法只能在VB.NET中才能行的通,在这里不行吧
      

  3.   

    1、给Button的Attribute属性加上Alert事件,如
       Button.Attribute.Add("onclick","<script>alert('弹出对话框')</script>");
    2、在Button的Click事件里写:
       Response.Write("<script>alert('弹出对话框')</script>");
      

  4.   

    LoveCherry(我爱成立) 的方法在c#中行
      

  5.   

    Button.Attribute.Add("onclick","<script>alert('弹出对话框')</script>");
    也是一种方法
    建议这种
      

  6.   

    你是指Button.Attribute.Add("onclick","<script>alert('弹出对话框')</script>")方法吗?
    它是在客户端执行,每次都有。
    贴出你的代码,让我看看
      

  7.   

    把这段代码放到
    if(!IsPostBack())
    {
    }
    中去
      

  8.   

    那为什么在服务器端第一次不出现呢?
    <Script Language="c#" Runat="server">
    void button1_onclick(Object sender,EventArgs e)
    { OleDbConnection conn=new OleDbConnection("provider=Microsoft.jet.OleDb.4.0;Data Source="+Server.MapPath("my.mdb"));
       OleDbCommand cmd=new OleDbCommand("insert into news(id,context)values('" + id.Text + "','" + context.Text +"')",conn);
        cmd.ExecuteNonQuery();
        buttton1.Attribute.Add("onclick","javascript;alert('添加纪录成功!')");
    }
    </script>
      

  9.   

    我在C#中测试过,下面的代码可行!
    源代码如下:
    private void Button1_Click(object sender, System.EventArgs e)
    {
    Response.Write("<script>alert('sdfsdf');</script>");
    }
      

  10.   

    说错了
    把这段代码this.Button1.Attributes.Add("onclick","alert('dfg')");
    放到Page_Load()下面
      

  11.   

    因为第一次按这个按钮的时候添加ONCLICK教本
    第二此才有效
    放到PAGE_LOAD下就可以了
    如果是直接response.write就放到click事件中
      

  12.   

    如果点击按钮时不让刷新页面,那么把this.Button1.Attributes.Add("onclick","alert('dfg')"放在Page_load()事件中岂不是毫无用处吗?
      

  13.   

    Page_Load是第一次装载这个页面的时候
    不一定是刷新
    你试试看就知道了
      

  14.   

    onclick事件
    {
    Response.Write("<script>alert('sdfsdf');</script>");
    }
    这是正确的
      

  15.   

    非常简单啥!
    在page_load里面加上:
    if(!IsPostBack)
    {
        Button1.Attributes.Add("onclick","javascript:return confirm('确认提交?');");
    }这样就可以了。