Day 1: ASP.NET and JavaScript Jan.16th Trying

 

  • ASP.NET has its own named controls(tags) corresponding to that in an HTML document, such as <asp:Label></asp:Label> corresponds to <label>. Currently, I have found the differences and some similarities: (taking label as an example): inside a tag, when setting its properties, id for <label> is equavalent with ID for <asp:Label>, and its ok for document.getElementById() to get both kinds of elements; however document.getElementByTagName() does not apply to <asp:Label> tags.
  • Javascripts is used to manipulate any element and css property in an HTML document. It offers three ways to find an element: by ID, by TagName, by Class.
  • There are three ways to show popup windows in javascripts: window.alert(); confirm(); prompt();
  • Three are many popular js frameworks like: jQuery.js, Angular.js, Bootstrap.js, vue.js, react.js,... so forth and so on, I know just very little parts of them, not to mention mastering them.
  • Asked questions on the internet are re-viewed by me. Like how to transfer variants from front part to end part in ASP.NET developing, and the answers are found: use <%=variantName%>; or use Request.Form[variantName]; or use Post way;
  • About calling javascript functions in front .aspx page from end part in .cs page, I have experienced a lot of searching( instead of researching):
    • Use Response.Write("<script>alert('Clicked')</script>"), to transfer few data to front; thus could only use some simple inline written functions.
    • Use ClientScript.RegisterStartUpScripts()/SciptsBlock(), which did not seem to work for me.
    • Use ScriptManager ONLY when you have a UpdatePanel tag in the front part. (as far as I know)
    • Use btn(the control from front).Attribute.Add("onclick","yourFunction();"), which is only allowed to written in Page_Load() method, meanwhile, it works like this: in any case executes javascript function in .aspx first, and then the event in .cs, which means it could be called twice in maximum.
  • About page self-refreshing problem when clicking an asp:Button run on server, the classical and still popular way is; AJAX; which is useful in asp.net. Another way is to set AutoPostBack attribute to false.
原文地址:https://www.cnblogs.com/ericwonne1996wangqifan/p/8298340.html