Get the App
SLTechnology News&Howtos  ›  Development  › 

How does ASP.NET AJAX understand?

Shulou Source: shulou.com Published: 2022-06-02 07:51:43 09月14日 Update

This article mainly explains "how to understand ASP.NET AJAX". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to understand ASP.NET AJAX".

Re-examine ASP.NET AJAX client Development with the idea of component

Default.aspx:

DOCTYPEhtmlPUBLIC "- / / W3C//DTDXHTML1.1//EN"

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >

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

< headrunat= "server" >

< title > UntitledPagetitle >

Head >

< body >

< formid= "form1" runat= "server" >

< asp:ScriptManagerID= "ScriptManager1" runat= "server" >

< Scripts >

< asp:ScriptReferencePath= "~ / ajax.js" / >

Scripts >

< Services >

< asp:ServiceReferencePath= "~ / SayHelloService.asmx" / >

Services >

Asp:ScriptManager >

< div >

< inputid= "btnSayHello" type= "button" value=

"SayHello" onclick= "btnSayHello_onClick ()" / >

< divid= "result" > div >

< / div >

< / form >

< / body >

< / html >

Ajax.js:

/ / JS function called when btnSayHello is clicked functionbtnSayHello_onClick () {SayHelloService.SayHello (OnSucceeded,OnFailded);} / callback function functionOnSucceeded (reusltText) {$get ("result") [xss_clean] = reusltText;} / / callback function functionOnFailded (error) {$get ("result") [xss_clean] = "failed. Error message:" + error.get_message ();}

This is a familiar JavaScript programming model: based on DOM operations. In this programming mode, all page elements are treated as a tree-like collection of DOM elements, and the corresponding DOM operations are used to obtain data or change the attributes of page elements. For example, if we want to get a value in a text box, we first use the document.getElementById (abbreviated to $get in the ASP.NET AJAX framework) method to get the DOM reference of the text box, and then get the value of its value property.

This programming mode can easily confuse us, such as text boxes, check boxes, submit buttons, DOM representations of ordinary buttons are all "input" elements, and we have to set the value of div or span using a name that is not very intuitive, such as innerHTML. In fact, for developers, especially those who have been engaged in server-side development for a long time, we prefer to think of text boxes as TextBox, check boxes as CheckBox, buttons as Button, div or span as Label, and we prefer to use statements like label1.text to set up the text in div rather than using innerHTML.

Fortunately, ASP.NET AJAX developers have obviously taken this into account, and the ASP.NET AJAX framework now allows us to use a server-side component-like programming model for client-side programming.

Thank you for your reading, the above is the content of "how to understand ASP.NET AJAX". After the study of this article, I believe you have a deeper understanding of how to understand ASP.NET AJAX, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Text programming elements patterns developers people functions buttons learning content clients clients properties servers frames components pages check boxes services general Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology macOS Huawei NVidia Shulou Tech Info