Suppose there is a button (not a submit , but a regular button), with the prefix asp ( asp:button ) and the attribute runat = server .

On the click event, she has a handler written in C # / VB / managed C ++ in codebehind. But, the browser, of course, does not understand C # / VB / managed C ++ and here I am confused, since there are 2 ways of processing:

  1. in order to handle the click event of the browser, after a click, it sends a request to the server, and the server starts a dll, in which there is code to handle the click on the button.
  2. Before sending the page to the browser from the very beginning, the server processes the click processing code written in C # / VB / managed C ++ into Javascript, and together with the page sends the js script to the browser, and the script written by js was processed when the button was clicked.

Question: ASP.NET: server controls (prefixed with ASP ) are processed on the server via C #, VB or on the client, via JS? Thank you in advance.

  • (with ASP prefix and runat = server attribute) - aspnetsharp
  • The server processes only get and post requests, the code for the C # / VB / managedc ++ genit, and already the post event generates js. When compiling asp, both the code (dll) and js are generated - so we can assume that it is executed from two sides. - nick_n_a

1 answer 1

The first script works.

When you click on the c runat=server button, which has the OnClick attribute specified, a request is made to the server. The class of the page with all controls is created anew on the server, the C # object of the Button type is recreated, and the state is loaded from ViewState into them. The Button object triggers a Click event.

After processing the event, the state is saved back to ViewState, the page is redrawn, and sent to the client.