Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

ASP.NET client


May 13, 2021 ASP.NET


Table of contents


Client

ASP.NET client encoding for this system has two aspects:

  • Client script: It runs in a browser and speeds up page execution in turn. For example, client data validity captures invalid data and alerts users accordingly without posting back in the server.
  • Client source code: ASP.NET web page forms the client source code. For example, ASP.NET Web page's HTML source code contains several hidden areas and automatically injects Java descriptive language code, preserving the information as if it were a view state, or other work to keep the page functioning properly.

The client script

All ASP.NET server controls allow the response to be coded in either the Java or VBS languages. S ome ASP.NET server controls use client-side scripts to react to user needs without posting them back to the server. For example, a data validity control.

In addition to these scripts, button controls have the appropriate OnClientClick method to execute client scripts when a button is clicked.

Traditional server HTML controls have several events that can execute a script when it is initiated:

Event Property
onblur Triggered when the control loses focus
onfocus Triggered when the control gets the focus
onclick Triggered when the control is clicked
onchange Triggered when the value of the control changes
onkeydown Triggered when the user presses the keyboard button
onkeypress When the user presses the alphanumeric button
onkeyup Triggered when the user releases the key
onmouseover Triggered when the user moves the mouse pointer over the control interface
onserverclick When the control interface is clicked, the ServerClick event control is started

The client source code

We've discussed client source code in the above. ASP.NET pages are usually written in two types of files:

  • Content documents or audited documents (.aspx)
  • The file behind the code

Content files contain HTML or ASP.NET control labels and text to form a page structure. T he file behind the code contains a classification definition. During runtime, the content file is parsed and transferred to a page class.

This page class, as well as the definition of the class in the encoding file and the system-generated encoding, together make up the execution encoding (integration), which processes all the postback data, generating responses and sending back customer actions.

Think about this simple page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
   Inherits="clientside._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

   <head runat="server">
      <title>
         Untitled Page
      </title>
   </head>

   <body>
      <form id="form1" runat="server">

         <div>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Click" />
         </div>

         <hr />

         <h3> <asp:Label ID="Msg" runat="server" Text=""> </asp:Label> </h3>
      </form>
   </body>

</html>

When this page is running in the browser, the View Source option displays html pages and sends them to the browser ASP.Net the user runtime:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

   <head>
      <title>
         Untitled Page
      </title>
   </head>

   <body>
      <form name="form1" method="post" action="Default.aspx" id="form1">

         <div>
            <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" 
               value="/wEPDwUKMTU5MTA2ODYwOWRk31NudGDgvhhA7joJum9Qn5RxU2M=" />
         </div>

         <div>
            <input type="hidden" name="__EVENTVALIDATION"  id="__EVENTVALIDATION" 
               value="/wEWAwKpjZj0DALs0bLrBgKM54rGBhHsyM61rraxE+KnBTCS8cd1QDJ/"/>
         </div>

         <div>
            <input name="TextBox1" type="text" id="TextBox1" />  
            <input type="submit" name="Button1" value="Click" id="Button1" />
         </div>

         <hr />
         <h3><span id="Msg"></span></h3>

      </form>
   </body>
</html>

If you browse the encoding properly, you'll find that the first two labels contain stored view state and hidden domains of valid data.