<asp:Button runat="server" ID="bntEdit" Text="确定"  OnClick="bntEdit_Click"   />
protected void bntEdit_Click(object sender, EventArgs e)
    {
        if (rStatus.SelectedValue == "4") bntEdit.OnClientClick = "return confirm('您确定要判为直接完成吗?\n\n请注意\n\n 实际交易量及实际单价 ')";
        if (rStatus.SelectedValue == "3") bntEdit.OnClientClick = "return confirm('您确定要判为等待确认吗?\n\n请注意\n\n 实际交易量及实际单价 ')";
        if (rStatus.SelectedValue == "7" && rProblemStatus.SelectedValue == "1") bntEdit.OnClientClick = "return confirm('您确定要判为顾客无法联系吗? ')";
        if (rStatus.SelectedValue == "7" && rProblemStatus.SelectedValue == "2") bntEdit.OnClientClick = "return confirm('您确定要判为供货商已无货吗? ')";
        if (rStatus.SelectedValue == "7" && rProblemStatus.SelectedValue == "3") bntEdit.OnClientClick = "return confirm('您确定要判为顾客未收到吗? ')";
}
为什么 不弹出 对话框拉?那些代码是执行了的,但是就是不出现我想要的结果啊

解决方案 »

  1.   

    改成这样
    if (rStatus.SelectedValue == "4")
    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "confirm", "<script language='javascript'>return confirm('您确定要判为直接完成吗?\n\n请注意\n\n 实际交易量及实际单价'); </script>");
      

  2.   

    我觉得这里存在一个事件生成的顺序问题。
    if (rStatus.SelectedValue == "4") 
    bntEdit.OnClientClick = "return confirm('您确定要判为直接完成吗?\n\n请注意\n\n 实际交易量及实际单价 ')"; 
    已经你是单击后触发了事件,然后才绑定了OnClientClick ,肯定是不会弹出对话框拉。1楼的方法应该可以。
      

  3.   

    光看代码我猜你是不是点2次就弹了?因为你能点这个按钮的时候页面已经加载完了,又因为你按钮的onclientclick是后台加上去的所以第一次加载的时候是没有这些代码的,所以你要写在后台的话是没有办法实现这个功能的,除非你让他每次点完按钮都把页面刷一次解决的办法就是把判断扔到JS里去,如果你做判断依据的这个下拉框没有其他数据需求的话就换成HTML控件吧,直接写JS判断
      

  4.   

    <asp:Button runat="server" ID="bntEdit" Text="确定"  onclick="showpop(this.options[this.selectedIndex].value)"  /> 
    function showpop(selvalue)
    {
    if(selvalue=='3')
    alert(message);
    .......
    }看看这样行不。
      

  5.   

    搞错了:要用这个
    <input type="button" id="bntEdit" value="确定" onclick="showpop(this.options[this.selectedIndex].value)" />