With several options to design web applications in MS ecosystem, like ASP.NET MVC, ASP.NET Web Forms, Single Page Applications. From the start of ASP.NET, it supported ASP.NET Web Forms and even today, enterprises develop many web applications using them. The web forms help you create faster web applications.
But it totally envelops the underlying technology, i.e., HTTP.
If you know the basics, you must know how to summon JavaScript from your code behind codes in ASP.NET Code.
In this article, we covered 3 basic things which every ASP.NET developer must know while using ASP.NET Web Forms.
The nature of HTTP and Request-Response pattern
All web applications are created using ASP.Net use HTTP protocol or its secured versions. You can consider HTTPS as using HHTP safely. HTTPS makes use of Secure Socket Layer (SSL) and encrypts your data. But, HTTPS still use HTTP.
HTTP is a no state protocol which follows a response/request pattern i.e., the user requests a resource and the web server sends the resource.
The web server never keeps any state of the previous requests. If the user requests for the same resource, the web server will respond as if the request was made for the first time. There are several ways to maintain the state in a web application. ViewState is one such way. Here all the data is coded in a hidden field and sent to the client and hence the state can be maintained between requests.
There are several other ways available to maintain the state which would be discussed later. For the time being, it is for your information that even though HTTP is stateless, there are certain options to maintain the state.
Role of CSS, HTML,Javascript, ASPX page in ASP.Net web application
Your browser can only understand HTML, CSS, JavaScript. So, the web technology must be converted into a technology that is based on HTML, CSS, and JS.
HTML provides the layout of the web page.
CSS or Cascading style sheet will help you in putting styles to the elements of the page.
JavaScript is used to process the elements at client side without hitting the server. JavaScript is used only for validation, to handle the user input, and to change the style of some element based on data or user input etc…
When a user reaches out to the ASP.NET web page, this is the sequence of events that occur:
User reaches out the web page
The request is sent to the server where the web application is hosted. The web server carries forward the request to ASP.NET because the requested resource is the aspx page.
.NET converts ASP.NET code into CSS, HTML and JS
The changed document is sent back to the user and the user gets the web page via the browser.
Differences between client side and server side
The ASP.NET server controls are changed into HTML elements at server side and the changed HTML parts are sent to the browser. To mention, JavaScript works only on HTML parts, and you must know the HTML element of ASP.NET server control that you are making use of to have the attributes changed.