Click Event Fires During Form Load
-
i created simple project using C# and added one textbox and button now i write code "TextBox1.Text = DateTime.Now.ToLongTimeString();" in button event and set breakpoint on this line now when i click on button in runtime event fires and textbox1.text becomes current time and breakepoint got yellow but now when i click on refresh the same event fires again plzzz help me aj
-
i created simple project using C# and added one textbox and button now i write code "TextBox1.Text = DateTime.Now.ToLongTimeString();" in button event and set breakpoint on this line now when i click on button in runtime event fires and textbox1.text becomes current time and breakepoint got yellow but now when i click on refresh the same event fires again plzzz help me aj
If you click Refresh like that, it's entirely the same as you click the button again. If you don't want that to happen, you may simply call the Response.Redirect method by the end of the click event handler:
Response.Redirect(Request.Url.AbsoluteUri);
However, you need to keep necessary information in order for the page to display correctly when the page is reloaded after the Response.Redirect method executes.