使用c#确认消息 [英] confirm message using c#

查看:81
本文介绍了使用c#确认消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



可以任何人告诉我

它是如何工作的。如何获得确定或取消按钮。



 string strconfirm =<   script  >  if(!window.confirm('On this Payment date+ DateTransaction) +有+ countpayments +在那里。你想以任何方式导入吗?。))<   / script  > ; 
CSM.RegisterClientScriptBlock(this.GetType(),Confirm,strconfirm,false);





谢谢

解决方案

嘿Sivarjun,



我知道有两种方法可以解决这个问题:

 ConfirmSave()
{
var Ok = confirm('你确定要保存更改吗?');
if(Ok)
返回true;
else
返回false;
}

------------------------------------- - //用于重定向到URL


函数ConfirmCancel(URL)
{
var Ok = confirm('您确定要取消更改吗? );
if(Ok == true)
{
document.location.href = URL;
}
// else
//返回false;
}



在服务器端,您可以添加此行以添加onclick的属性()

 btnSave.Attributes [onclick] =javascript:return ConfirmSave();; 
btnCancel.Attributes [onclick] =javascript:ConfirmCancel('InspectionNew.aspx');;





或者你可以尝试:



  if  true 
{
// 您的代码
}
else
{
Page.ClientScript.RegisterStartupScript( this .GetType(), open show(); true );
}





并在您的页面中:



< pre lang =HTML> < script 类型 = text / javascript >
function show()
{
if (确认(' 确定?') )
{
window location .replace(' yourpage.aspx');
}
}
< / script >





Hope这有帮助。


Hi all

can any one tell me
how it is work. and how can I get OK or cancel buttons.

string strconfirm = "<script>if(!window.confirm('On this Payment date " + DateTransaction + " there are " + countpayments + " are there. Do you want to Import any way?.'))</script>";
                          CSM.RegisterClientScriptBlock(this.GetType(), "Confirm", strconfirm, false);



Thank you

解决方案

Hey Sivarjun,

I know of two ways how you can go about this :

ConfirmSave()
     {        
        var Ok = confirm('Are you sure want to save the changes?');
         if(Ok)
             return true;
         else
             return false;
     }

 ---------------------------------------//For redirection to the URL
 

function ConfirmCancel(URL)
     {        
        var Ok = confirm('Are you sure want to Cancel the changes?');
         if(Ok == true)
         {
             document.location.href=URL;            
        }        
        //else
             //return false;
     }


In server side you can add this line for adding attributes of onclick()

btnSave.Attributes["onclick"] = "javascript:return ConfirmSave();";            
btnCancel.Attributes["onclick"] = "javascript:ConfirmCancel('InspectionNew.aspx');";



or you could try :

if (true)
        {
            //Your code
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "open", "show();", true);
        }



and in your page :

<script type="text/javascript">
        function show()
        {
            if(confirm('r u sure?'))
            {
                window.location.replace('yourpage.aspx');
            }
        }
    </script>



Hope this helps.


这篇关于使用c#确认消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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