How do change the events in a button with a script? With this question I mean to ask how do you change the order of events that happen in a button with a script, so that one happens before the other and then they can switch?
Hi, I am not sure but based on my understanding you are looking for this information Postback Event Processing Sequence Here are the events (and the order) that are raised when a Button is clicked and a postback occurs: Page.Init + Control.Init for every control on the Web Form The first stage in the page life cycle is initialization. After the page’s control tree is populated with all the statically declared controls in the .aspx source the Init event is fired. First, the Init event for the Page object occurs, then Init event occurs for each control on the Page. Viewstate information is not available at this stage. Page.LoadViewState After initialization, ASP.NET loads the view state for the page. ViewState contains the state of the controls the last time the page was processed on the server.
Page.ProcessPostData Post Data gets read from the request and control values are applied to control initalized in stage 1. Page.Load + Control.Load for each control on the Page If this is the first time the page is being processed (Page.IsPostback property), initial data binding is performed here. “Change” events are fired for controls (TextChanged, SelectedIndexChanged, and similar) The current value (from Post Data) is compared to the original value located in the ViewState. If there is a difference “Changed” events are raised. Server-side events are fired for any validation controls Button.Click + utton.Command
The Click and Command events are fired for the button that caused the postback Page.PreRender + Control.PreRender Page.SaveViewState New values for all the controls are saved to the view state for another round-trip to the server. my ford benefits
Well if you are set on doing it through code you could do something like this.
public Button buttonToClick
bool buttonClicked = false
void Update()
{
if (!buttonClicked && buttonToClick.clicked)
{
MethodA():
MethodB();
buttonClicked = true;
}
else if (buttonClicked && buttonToClick.clicked)
{
MethodB();
MethodA();
buttonClicked = false;
}
}
This should work, although I wrote it on my phone and didn’t test it lol