ASP tutorial two

xiaoxiao2021-03-06  19

Fourth, the sharpener is not misleading Chai Mong --ASP foundation 1. The result (string information) is output to the browser, the syntax is: Response.write displayed. As can be seen from example wuf2.as, "<% = display content%>" can be used instead of "content%>" displayed by "<%" ". 2. Use variables, wuf2.asp can be changed to:

<% @Language = VBScript%> <% 'single quotes After adding Note - WUF3.ASP Option Explicit' requires variable declaration, using it can reduce the possible possible, improve the efficiency DIM ipaddr 'before using variables, IPADDR = Request.SerVariables ("remote_addr")%> ip address = <% ipaddr%>

1. Use functions in the program

<% @Language = VBScript%> <% response.expires = 0%> Using function - wuf4.asp </ title> </ head> <body <p> Today's date: < % = DATE%> </ p> <p> current time: <% = Time%> </ P> <p> current time: <font color = "# cc0033> <% = time%> </ Font> </ p> <p> response.write "<p> current time: <font color = '# cc0033'>" & Time & "</ font> </ p>%> </ body> </ HTML></p> <p>In the above example, "&" is equivalent to " ", Date and Time are functions (note: The time available here is the time of the web server instead of the machine where the browser is located, from here the verification the ASP command is in the server End execution), ASP has many other functions, this article cannot be listed one by one, please check it yourself.</p> <p>As for <% response.expires = 0%>, we know that the browser can cache the web page to accelerate access, and response.expires is used to set the web page to keep the time (minutes) in the client browser cache. If set to 0, it indicates that the web page data will not be retained in the client's cache. It must be placed before the label. In this example, if you don't have this setting, you only press the "Refresh" button, the time will be updated, but only in the address bar, the time will not change, and after this sentence, each knock Enter a time, time will be updated. 4. Use conditional statement:</p> <p><% @Language = VBScript%> <% 'wuf5.asp if time <= # 12: 00 # THEN RESPONSE.REDIRECT "WUF1.ASP" elseif Time <= # 18: 00 # THEN Response.Redirect " WUF2.ASP "else response.redirect" wuf3.asp "Endi%> The date is included with ##, response.redirect is responsible for booting the client browser to display a new page, that is, the redirection, remember, this feature is very useful. 5. Use a loop statement:</p> <p><% @ Language = vbscript%> <% option explicit%> <html> <body> <% DIM I while i <= 5 response.write "</ p>" & "there is other loop structure, such as: do. ..Loop while, "& _" do while ... loop, for ... next, for each ... next, "&" </ p> "i = i 1 wend%> </ body> </ HTML></p> <p>From the above example, you should pay attention to how to use "_". 6. Use include file.</p> <p>For a Web site, the top or tail of each page is generally the same, then you can put these identical parts, and then reference it when you need it. First edit a file called comm.asp as follows:</p> <p><html> <head> <style type = "text / css"> <! - font {font-family: "Song", "Times New Roman"; Font-size:</p> <p>9pt} -> </ style> </ head> <body> <table width = "640" border = "0" bordercolor = "# 9999ff" bordercolor = "# ffffff" bordercolorlight = "# 3333ff" bordercolordark = "# CC0000> <tr bgcolor = "# 006666" Bordercolor = "# 009933"> <TD align = "center" height = "18" colspan = "2"> ⊙ "Fengzi Home" Copyright - </ font> < Font Color = "# fff00"> Construction is stationed in March 1997 </ font> </ td> </ TR> </ table> </ body> </ html></p> <p>Edit the following files:</p> <p><% @Language = VBScript%> <html> <body> <% 'wuf7.asp response.write output to the browser. "%> <! - # include file =" comm.asp "-> < / Body> </ html> include file can be placed any location of the web page, but must be externally of all ASP code blocks. In addition, there is a concept of process, function, parameter transmission, etc. If you have not been touched before, it is put it first, first understand the ASP, then gradually refine.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-49704.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="49704" 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.048</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 = 'Dzmg_2Fe_2FIN58pa2WnTcAZZTyug5_2F8s_2FsoLdY7Z578toqetr_2FczoP4Uw3DDxupHpvpnANU12QClEBDfSpAJFWtQg_3D_3D'; 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>