如果某些条件为真,我想显示带有'ok'和'Cancel'按钮的消息 [英] I want to show a message with 'ok' and 'Cancel' button if some condition is true

查看:57
本文介绍了如果某些条件为真,我想显示带有'ok'和'Cancel'按钮的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 button_click()
{
if (condition == true
{
弹出一个带有OK的消息并取消
如果(用户点击' ok'
{
然后是一些代码......;
}
else
{
退出;
}
}
}

解决方案





您无法在单个进程中集成或组合两个请求。

我的建议是接近jquery或异步请求。使用jquery来检查服务器上的条件,如果为true则返回将所需数据发布到服务器。执行然后一些代码





更新答案



 <   html     xmlns   =  http ://www.w3.org/1999/xhtml   >  
< head runat = 服务器 >
< title > < ; / title >
< script src = Scripts / jquery-1.4.1.js type = text / javascript > < / script >
< script src = Scripts / jquery-1.4.1-vsdoc.js 类型 = text / javascript > < / script >
< script language = javascript >
function savefile(){


.post( default3。 aspx?action = checkfile,{filename: document .getElementById( fileupload1)。value}, function (data){
if (data == ' Yes'){
if (确认( 你确定)) {

}
}
else {

}
}) ;
}
< / 脚本 >



< / head >
< ; 正文 >
< 表格 id = form1 runat = server >

< div id = maincontent runat < span class =code-keyword> = server >
< 输入 type = file id = fileupload1 / >
< 输入 type = button value = 保存文件 id = btnsave onclick = savefile() / > ;

< / form >
< / body >
< / html >





和背后的代码文件包含

 受保护  void  Page_Load(  object  sender,EventArgs e)
{
if (Request.QueryString [< span class =code-string> action]!= null
{
if (Request.QueryString [ action]。ToString()== checkfile
{
Response.Clear();

bool execsts = true ;
// 检查天文是否存在
// 如果存在,则将响应发送给客户端为是
if (execsts)
{
// 如果确认存在,则将响应发送为是
Response.Write( );
}
其他
{
// < span class =code-comment>保存文件(如果不存在)
Response.Write( 文件已成功保存);
}


Response.End();
}

}
}





这只是为了带来只有想法



你必须根据你的要求进行修改。



全部最好


检查以下代码。

 <   asp:按钮    id   =  btn    runat   =  server   < span class =code-attribute>  OnClientClick   =  javascript:return confirm('Are你确定吗?')     /  >  


button_click()
{
  if(condition== true)
  {
   popup a msg with OK and cancel
   if(user click 'ok')
   {
     then some code...;
   }
  else 
   {
      exit;
   }
  }
}

解决方案

Hi,

you can not integrate or combine two requests in single process.
my suggestion is approach jquery or asynchronous requests.to check condition on server from client using jquery thn if true in response post required data to server .to perform "then some code"


updated Answer

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script language ="javascript" >
        function savefile() {


.post("default3.aspx?action=checkfile", { filename: document.getElementById("fileupload1").value }, function (data) { if (data == 'Yes') { if (confirm("Are you Sure")) { } } else { } }); } </script> </head> <body> <form id="form1" runat="server"> <div id="maincontent" runat="server" > <input type ="file" id="fileupload1" /> <input type ="button" value ="Save File" id="btnsave" onclick ="savefile()" /> </form> </body> </html>



And code behind file contains

protected void Page_Load(object sender, EventArgs e)
{
    if (Request.QueryString["action"] != null)
    {
        if(Request.QueryString ["action"].ToString()=="checkfile")
        {
            Response.Clear();

            bool execsts = true ;
            //check wheather file is exists or not
            //if exists send response to client as Yes
            if (execsts)
            {
                //send response as Yes if it exists to confirm
                Response.Write("Yes");
            }
            else
            {
                //save file if it doesn't exists
                Response.Write("File Saved Successfully");
            }


            Response.End();
        }

    }
}



This just for bring idea only

you''ve to modify it for your requrement.

All the Best


Check the below code.

<asp:button id="btn" runat="server" OnClientClick="javascript:return confirm('Are you sure?')" />


这篇关于如果某些条件为真,我想显示带有'ok'和'Cancel'按钮的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆