Learning ASP.NET Experience (1)

zhaozj2021-02-17  49

in

ASP.NET

Middle, whole

Web

The page is placed in a big form. Such as:

******** </ Title></p> <p></ HEAD></p> <p><Body></p> <p><Form name = "form1" action = "*****"></p> <p>The specific content of the web page ...</p> <p></ Form></p> <p></ Body></p> <p></ Html></p> <p>Many HTML controls such as buttons, drop-down menus, text boxes, etc. may be placed in this form. ASP.NET provides some server-side web controls. When executed on the server, through a certain condition, the web form converts these server web controls to a normal HTML control. For example, a button:</p> <p><ask: button id = "b_submit" runat = "server" width = "37" height = "22" text = "determined" backcolor = "dodgerblue" bordercolor = "lavender" forcolor = "white"> </ asp: button ></p> <p>After the conversion is changed:</p> <p><input type = "submit" name = "B_SUBMIT" value = "OK" ID = "b_submit" style = "color: white; background-color: DodgerBlue; border-color: lavender; height: 22px; width: 37px;" /></p> <p>In fact, ASP.NET uses or has some existing technologies. It is only, it has been encapsulated these existing technologies so that you will increase yourself to an application level.</p> <p>In ASP.NET, a web form is seen as an object. Its data member is the variables that Web controls and your own definition, and its function members are those functions used to respond to client operations, of course, you have defined functions. I roughly explained what incident occurred when the user requested a web page:</p> <p>Note: A web page is implemented by three files: HTML, background program code, resource file.</p> <p>Suppose: There is a tab control and a button control in the web page. When the text is initially: "Initial"</p> <p>First, the user performs the page to execute the page_init process of the web page for the first time, and the components are typically initialized. Then execute the Page_Load process, here, we can do some initialization work. For example: Set the text of the label control: "Initial". Then, since the user is the first request page, there is no other event. Program Control is converted to interpret server code in the HTML code page. In HTML, there is a <ask: label> this is our label control. Because we have valued the text of the label during the page_load, now the program will now convert <asp: label> to <span id = "label1" style = "width: 102px;"> Initial </ span>. And button conversion is similar to what I have already said. After these conversions, the code in the HTML page becomes a standard code. These codes are then obtained by the user browser. After parsing, the user can see a "initial" and a button. Now, the user clicks on the button. So, the form is submitted. (The details of the submit, I will say below)</p> <p>By submitting a form, the server knows that this is the user clicking on the button control. And this is the user's second time requesting the page. Thus, the program executes the PAGE_INIT process, and the Page_Load process. At this time, because the user clicks the button control, the program starts to perform another function, which is used to deal with the user's click control. Here, we set the text of the label control to: "click". The program is then transferred to the HTML page. Like the first request above. So the user can see a "click" and a button through the browser through the browser.</p> <p>In actual use, the program code in the background is compiled into binary code.</p> <p>Let's talk about the details of the submission form.</p> <p>The user's operation usually produces some events, but it is some client events. That is to say that these are not related to the server. To get in touch with the server, you must pass the request. Microsoft chose to submit it.</p> <p>In .NET, the content of the web form is placed in a big form. For the button, Microsoft converts them to <input type = "submit"> is the submission button in HTML. Because each button ID, Name is different, so the server can tell which button is pressed, and then generates the corresponding server event. As the user in the above example click the button event. And perform the corresponding operation. For other controls such as the drop-down menu, if you want to process by the server after the user changes the selection of the menu, you also need to convert the client event to a server-side event. NET adds a few <input type = "hidden" in the form. When the user changes the menu selection, a client event onchange will generate. Microsoft provides a universal function _Dopostback (); viewing web source files can be seen, there is οnchange = "__ dopostback in the drop-down menu.". Here is the source code of this function:</p> <p>Function __dopostback (evenettarget, eventargument) {</p> <p>Var theform = Document.form1; // Form1 is the name of the form</p> <p>Theform .__ EventTarget.Value = EventTarget; // __EventTarget is Hidden</p> <p>Theform .__ Eventargument.Value = Eventargument; //_Eventargument is Hidden</p> <p>Theform.submit (); // Submit a form</p> <p>}</p> <p>In fact, you can see that .NET is the name of the control of the client by hiding the control, such as the number of controls that generate events. Then, submit the form. In this way, the server side can determine the name of the control generated by the hidden control, and generate server events, which will process the event.</p> <p>can be seen,</p> <p>ASP.NET</p> <p>Relatively</p> <p>ASP 3.0</p> <p>Different places</p> <p>.NET</p> <p>Package a lot of features and provide a lot of new server components. Make the program more simple. in</p> <p>ASP3.0</p> <p>In the middle, the program code is embedded.</p> <p>HTML</p> <p>Code in the code. The advantage is that the flexibility is higher, but it is not easy to add a lot of features in the same page (because face a large number of embedded</p> <p>HTML</p> <p>In the code</p> <p>ASP</p> <p>Code, the incorrect generation is difficult to avoid). in</p> <p>ASP.NET</p> <p>In these, these have been changed.</p> <p>.NET</p> <p>Put the program code</p> <p>HTML</p> <p>The code is divided. And providing a large number of convenient server controls. This makes it developed</p> <p>ASP.NET</p> <p>Programs become very simple. But in the actual use process, I found that if it is too dependent on these controls, the flexibility of programming will become smaller. And there is a lot of discovery during use.</p> <p>Bug</p> <p>.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-29847.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="29847" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.036</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'qBaQw7FfF_2Bzlz5QuLTpy0Gk583Wt0VGnOR1SVepT9yZ3ei1TqB_2BUaCu0us_2FgMOOc4d_2B8aOChTAmPeg6Y'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>