Click here to Skip to main content
15,997,776 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In asp.net with c#,I have a code in button click event.
C#
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.
Posted

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900