日期:2014-05-18 浏览次数:20622 次
private void button1_Click(object sender, EventArgs e)
    {
      bool condition = true;
      // Check the condition here...
      if(condition)
      {
        DialogResult dlg = MessageBox.Show("leoeofofofoog", "Test", MessageBoxButtons.OKCancel);
        if(dlg == DialogResult.OK)
        {
          //Do something.
        }
        else
        {
          // Do nothing.
        }
      }
    }
------解决方案--------------------
如果你的判断什么的是在服务器端完成的话,最好是用AJAX来完成了.
点击button回调进行判断.
再根据回调的结果弹出对话框
------解决方案--------------------
直接confirm
------解决方案--------------------
用js在客户端做验证???
if (条件){
    if(confirm('提示')){
        form1.submit;//触发服务器事件
        return true;
    }
    return false;//取消的话
}
------解决方案--------------------
同意2楼的方法。或者在执行方法时用AJAX
------解决方案--------------------
WebForm也容易
private void button1_Click(object sender, EventArgs e)
{
bool condition = true;
if (condition)
{
   if (confirm("确定吗?"))
{
//Do something.
}
else
{
// Do nothing.
}
}
}
------解决方案--------------------
-_-!   好快的楼啊
------解决方案--------------------
除了使用AJAX,很难做到这样,除非弹出层.
为了让问题简单而且合理的,应该是在一单击BUTTON时就询问.
------解决方案--------------------
 protected void Button1_Click(object sender, EventArgs e)
   {
       if (1 == 1)
       {
           Response.Write("<script language=javascript>confirm('提示信息。');</script>");
           if (true)
           {
               //执行这里语句
           }
           else  
           {
               //执行这里语句
           }
       }
   }
------解决方案--------------------
使用层,里面做一个确定和取消两个按钮,你点击就弹出层,点击那个按钮就执行那个按钮的事件
------解决方案--------------------
if (条件){
   if(confirm('提示')){
       form1.submit;//触发服务器事件
       return true;
   }
   return false;//取消的话
}
-------------
这个是可以的
------解决方案--------------------
LZ是在按鈕的屬性裡設置的Visible = "false"的吧,那在前端當然不能獲取到這個按鈕了.你只能使用js設置隱藏的按鈕button.style.visibility = 'hidden',這樣才能在前端獲取這個隱藏的按鈕
設計頁面aspx的代碼:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="hidden.aspx.cs" Inherits="Test_hidden" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>未命名頁面</title>
    
    <script type="text/javascript">
    <!--
    
    function CheckShow()
    {
        var condition = document.getElementById('<%=this.hdnCondition.ClientID %>').value;
        var input = document.getElementById('<%=this.txtInput.ClientID %>').value;
        
        if (input == condition)//判斷條件是否成立
        {
            if (window.confirm('Do you want to do?'))
            {
                document.getElem