在代码后面打开确认框 [英] opening confirm box in code behind

查看:107
本文介绍了在代码后面打开确认框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用c#的asp.net中,我在按钮单击事件中有一个代码.

In asp.net with c#,I have a code in button click event.

if (TextBox1.Text.Equals(""))
       {
           Label1.Text = "Put your User Id";
           Label1.ForeColor = System.Drawing.Color.Red;
           TextBox1.Focus();
       }
       else if (TextBox2.Text.Equals(""))
       {
           "code here"
           Label1.Text = "Put your Password";
           Label1.ForeColor = System.Drawing.Color.Red;
           TextBox2.Focus();
       }


在此处的代码"位置的否则"之后,我要显示一个确认框,如果按确定",则将执行其余代码.如何?请帮助.


after the "else if" in the position of "code here",I want to show a confirm box,and if "ok" is pressed then the rest of the code will be executed.How?Please help.

推荐答案

您不能这样做.您的C#在服务器上运行,并且所有C#都将在客户端任何代码执行之前执行.您需要使用JavaScript中的Confirm()函数,然后将代码移入JS或将其移入WebService,然后返回JS.您的C#代码不能等待JS执行.用户未连接到您的服务器. HTTP是无状态的.
You can''t do that. Your C# is running on the server and ALL of it will execute before any code on the client side will execute. You need to use the confirm() function in JavaScript and either move your code into JS or move it into a WebService that then returns to JS. Your C# code can''t wait for JS to execute. The user is not connected to your server. HTTP is stateless.


这篇关于在代码后面打开确认框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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