Separation of program framework and program code in ASP.NET

xiaoxiao2021-03-06  45

A year ago, when I got a PHP program named Twig, I immediately was discouraged by the author's OOP. It is hard to imagine all the features in Twig (in trouble, email, personalization) all in a PHP file (Index .PHP3) is executed in the implementation, which benefited from the author's idea of ​​using the program code and the page architecture, but I also see although the author has made great efforts, but due to the limitations of PHP, the program did not really do Separation of code and architecture, index.php3 this primary file is much more powerful because of much functions to be executed, so that the entire file is still very zero, I spent half a month. Time, you really understand the architecture of the program, analyze the bitterness of the code, no one can know (然 tears ...).

The TWIG program has a great impact on my future programming, but even such a work, there is still no situation in which the program code is mixed with the HTML code.

The separation of program code and page architecture is a dream of web programmers for many years. Before ASP.NET appears, whether it is ASP, PHP or JSP, the program code and HTML code are mixed together, this approach, although it is praised in the initial period of Web technology, but over time, its drawback It is increasingly obvious. When the program code is very long, the HTML code is mixed, and the readability of the program has become very poor, which is unable to distinguish the page architecture that the program really wants to represent.

The new technologies ASP.NET truly code separation through the CodeBehind, User Control, and Custom Control. This is an amazing progress, and everyone can see how clear the structure of the ASP.NET program after separation of the code is here.

The flying knife take it to everyone to demonstrate their specific implementation methods, let's take a look at the functions you want to achieve.

For ease of understanding, the page designed here is simple, the page is divided into three main parts, the head contains an ADROTATOR control (to display an advertisement) and a Label control (to display the current ad link address); the middle is a landing Page, including two TextBox controls (used to enter usernames and passwords, one Label control (display login is successful) with a Button control (as submission button); bottom contains two Label controls (display the current user name, respectively User rights).

Friends who are familiar with Asp.Net, immediately realize that the header must have an onadcreated event to display the corresponding link in the Label control; and the central part is an OnClick event. deal with.

1 Codebehind

First we see how to use the CodeBehind method to implement the separation of the code and the page architecture, the source program given below is the primary ASP.NET program --Example1.aspx:

<% @ Page src = "cseventhandle.cs" inherits = "ASPCN"%>

</ title></p> <p></ hEAD></p> <p><body></p> <p><form runat = "server"></p> <p><asp: panel id = "header" runat = "server"></p> <p><asp: adrotator id = "ad" AdvertisementFile = "Adbannersad.xml" borderwidth = "0" onadcreated = "adcreated" runat = "server" /> <br> Current ad link: <ask: label id = "lbladtext" Forecolor = "Red" runat = "server" /></p> <p></ asp: panel></p> <p><ask: panel id = "logon" runat = "server"></p> <p><table></p> <p><tr> <td colspan = "2" align = "center"> <b> login window </ b> </ td> </ tr></p> <p><TR> <TD COLSPAN = "2" align = "center"> <ask: label id = "lblmsgshow" forcolor = "red" runat = "server" /> </ td> </ tr></p> <p><TR> <TD> User Name: </ TD> <TD> <asp: TextBox ID = "TBUSERNAME" runat = "server" /> </ td> </ tr></p> <p><TR> <TD> Password: </ TD> <TD> <asp: textbox id = "tbpasswd" textmode = "password" runat = "server" /> </ td> </ tr></p> <p><TR> <TD> <asp: button id = "btnsubmit" text = "Login" onclick = "submit_click" runat = "server" /> </ td> </ tr></p> <p></ TABLE></p> <p></ asp: panel></p> <p><asp: panel id = "footer" runat = "server"></p> <p>Username: <asp: label id = "lblusername" font-name = "arial" forcolor = "red" text = "Visitor" runat = "server" /></p> <p>Permissions: <asp: label id = "lblpurview" font-name = "arial" text = "None" forcolor = "red" runat = "server" /></p> <p></ asp: panel></p> <p></ form></p> <p></ body></p> <p></ html></p> <p>In the routine, you can clearly see that there is no C #, VB, JavaScript in the program to handle ONADCREATED and the OnClick event, but execute this program, the program can be used normally (as shown in Figure 2-1 and Figure 2-2). This is the result of using CodeBehinde, and event processing has been transferred to other programs definition. Please pay attention to this information in this example: <% @ Page src = "cseventhandle.cs" inherits = "ASPCN"%></p> <p>Generally in the ASP.NET program, the PAGE instructions are set in what language (using the language property), and the language attribute does not appear in this example, but two new Page properties appear: SRC and Inherits. The src property sets the event processing true code location, the inherits property sets the class name that needs to be introduced. You can see that the file defined in this example is EventHandle.cs, let's take a look at its specific content:</p> <p>Using system;</p> <p>Using system.data;</p> <p>Using system.data.sqlclient;</p> <p>Using system.Web;</p> <p>Using system.Web.ui;</p> <p>Using system.Web.ui.webcontrols;</p> <p>Using system.Web.ui.htmlcontrols;</p> <p>Public Class Aspcn: PAGE</p> <p>{</p> <p>// Declare the controls that appear in the web form</p> <p>Public label lbladtext, lblusername, lblpurview, lblmsgshow</p> <p>Public TextBox Tbusername, Tbpasswd;</p> <p>Public button btnsubmit;</p> <p>Public adrotator ad;</p> <p>Private string strconnstring = "server = (local) / feidao; database = aspcn; trusted_connection = yes";</p> <p>// Process the ADROTATOR control establishment event</p> <p>Public void adcreated (Object SRC, AdcreatedEventArgs E)</p> <p>{</p> <p>LBLADTEXT.TEXT = E.AlternateText;</p> <p>}</p> <p>Public void Submit_Click (Object Sender, Eventargs E)</p> <p>{</p> <p>SqlConnection myconn = new sqlconnection (strConnString);</p> <p>Myconn.open ();</p> <p>String strusername, strpassword, strselect;</p> <p>Strusername = tbusername.text;</p> <p>Strpassword = tbpasswd.text;</p> <p>strSelect = "SELECT * from bbs_user where id = '" strusername "' and password = '" strpassword "";</p> <p>Sqlcommand mycomm = new sqlcommand (strsElect, myconn);</p> <p>SqlDataReader DR = mycomm.executeRead ();</p> <p>IF (Dr.Read ())</p> <p>{</p> <p>//Landed successfully</p> <p>LBLMSGSHOW.TEXT = "Login Success";</p> <p>LBLUSERNAME.TEXT = DR ["ID"]. TOSTRING ();</p> <p>LBLPurView.text = DR ["purview"]. TOSTRING ();</p> <p>Else</p> <p>{</p> <p>// Landing unsuccessful</p> <p>LBLMSGSHOW.TEXT = "Landing Unsuccessful";</p> <p>}</p> <p>Dr.close ();</p> <p>MyConn.close ();</p> <p>}</p> <p>}</p> <p>Event processing is to define in a class (this example is ASPCN, accounting case), and this class must inherit the Page class because you need to associate with the web forms.</p> <p>Analysis program, you can see that the processing operation of the event in the program is the same as the procedure that is not code-separated, and there is nothing special place. (I believe in the relevant annotations already given in the program, I believe it is helpful to understand the procedures for everyone)</p> <p>After using CodeBehind technology, you need to write some code, such as declarative controls, etc., maybe everyone does not like to write such a code, but everyone must see that the readability of the main program has increased after using CodeBehind technology. I believe that everyone can distinguish all parts of the page architecture soon. Everyone thinks if these architects can be seen so clearly if other technologies can be seen?</p> <p>(The program here is only used, huh, huh, do you want to catch me what quoted vulnerabilities are 哟哟 哟)</p> <p>2 User Controls (UserControl)</p> <p>CodeBehind technology has truly realized the separation of code and architecture than before, it is a big step, but its defect is also obvious, such as the landing area in the middle of the main page, if there are many content, HTML display code is still occupied The area of ​​the program is still reduced.</p> <p>ASP.NET also provides a solution, which is the user control.</p> <p>User Control We can treat it as a Server control without compilation. Oyasting the control, then it will definitely follow the method of use of the control. We look into a control in each Panel in Example1.aspx, so the main part of Example1.aspx can reduce only three lines by using the user control:</p> <p><% @ Register tagprefix = "aspcn" tagname = "header" src = "UserControls / header.ascx"%></p> <p><% @ Register tagprefix = "aspcn" tagname = "logon" src = "UserControls / logon.ascx"%></p> <p><% @ Register tagprefix = "aspcn" tagname = "footer" src = "UserControls / Footer.ascx"%></p> <p><html></p> <p><HEAD></p> <p><title> </ title></p> <p></ hEAD></p> <p><body></p> <p><form runat = "server"></p> <p><aspcn: header id = "myHeader" runat = "server" /></p> <p><aspcn: logon ID = "MyLogon" runat = "server" /></p> <p><aspcn: Footer ID = "Myfooter" runat = "server" /></p> <p></ form></p> <p></ body></p> <p></ html></p> <p>Executing this program, its operation is the same as the result of using CodeBehind technology, but the current ASP.NET program is easier to distinguish between page architectures. <aspcn: header id = "myHeader" runat = "server" /></p> <p><aspcn: logon ID = "MyLogon" runat = "server" /></p> <p><aspcn: Footer ID = "Myfooter" runat = "server" /></p> <p>These three lines of code use three user controls, so fewer code you can clearly see the page is divided into three parts.</p> <p>To use the User Control, you must use the register directive, the tagprefix property is defined as a namespace name to ensure that it is unique in this page; the tagname property is an alias that defines a class (Class), because the user control is executed CLR compiles to execute, so you must give a unique name for each user control in this program, so that everyone is distinguishing; SRC attributes are specifically pointed out the file name of the user control used (user controls .ascx) end).</p> <p>The use of user controls is the same as the normal Server control:</p> <p><namespace: class ... runat = "server" /></p> <p>Namespace represents the defined namespace, the Class is the corresponding class name, and the specific examples are:</p> <p><aspcn: logon ID = "MyLogon" runat = "server" /></p> <p>Below is the specific content of the user control used in the user control display program:</p> <p>HEADER.ASCX (Header User Control)</p> <p><Script language = "c #" runat = "server"></p> <p>Private Void ADCREATED (Object SRC, AdcreatedEventArgs E)</p> <p>{</p> <p>LBLADTEXT.TEXT = E.AlternateText;</p> <p>}</p> <p></ script></p> <p><asp: adrotator id = "ad" advertisementfile = ". Adbannersad.xml" borderwidth = "0" onadcreated = "adcreated" runat = "server" /> <br></p> <p>Current ad link: <ask: label id = "lbladtext" forcolor = "red" runat = "server" /></p> <p>Logon.ascx (Logon User Control)</p> <p><% @ Import namespace = "system.data"%></p> <p><% @ Import namespace = "system.data.sqlclient"%></p> <p><Script language = "c #" runat = "server"></p> <p>Protected string strconnstring = "server = (local) / feidao; database = aspcn; trusted_connection = yes";</p> <p>// Define the properties of UserControl</p> <p>Public String Username</p> <p>{</p> <p>get</p> <p>{</p> <p>Return TBUSERNAME.TEXT;</p> <p>}</p> <p>set</p> <p>{</p> <p>TBUSERNAME.TEXT = VALUE;</p> <p>}</p> <p>}</p> <p>Public String Password</p> <p>{</p> <p>get</p> <p>{</p> <p>Return tbpasswd.text;</p> <p>}</p> <p>set</p> <p>{</p> <p>Tbpasswd.text = value;</p> <p>}</p> <p>}</p> <p>// Event processing</p> <p>Private Void Submit_Click (Object Sender, Eventargs E)</p> <p>{</p> <p>SqlConnection myconn = new sqlconnection (strConnString);</p> <p>Myconn.open ();</p> <p>String strusername, strpassword, strselect;</p> <p>Strusername = tbusername.text;</p> <p>Strpassword = tbpasswd.text;</p> <p>strSelect = "SELECT * from bbs_user where id = '" strusername "' and password = '" strpassword "";</p> <p>Sqlcommand mycomm = new sqlcommand (strsElect, myconn);</p> <p>SqlDataReader DR = mycomm.executeRead ();</p> <p>IF (Dr.Read ())</p> <p>{</p> <p>//Landed successfully</p> <p>LBLMSGSHOW.TEXT = "Login Success";</p> <p>Session ["UserName"] = DR ["ID"]. TOSTRING ();</p> <p>Session ["PurView"] = DR ["purview"]. TOSTRING ();</p> <p>}</p> <p>Else</p> <p>{</p> <p>// Landing unsuccessful</p> <p>LBLMSGSHOW.TEXT = "Landing Unsuccessful";</p> <p>}</p> <p>Dr.close ();</p> <p>MyConn.close ();</p> <p>}</p> <p></ script></p> <p><table></p> <p><tr> <td colspan = "2" align = "center"> <b> login window </ b> </ td> </ tr></p> <p><TR> <TD COLSPAN = "2" align = "center"> <ask: label id = "lblmsgshow" forcolor = "red" runat = "server" /> </ td> </ tr></p> <p><TR> <TD> User Name: </ TD> <TD> <asp: TextBox ID = "TBUSERNAME" runat = "server" /> </ td> </ tr></p> <p><TR> <TD> Password: </ TD> <TD> <asp: textbox id = "tbpasswd" textmode = "password" runat = "server" /> </ td> </ tr></p> <p><TR> <TD> <asp: button id = "btnsubmit" text = "login" onclick = "submit_click" runat = "server" /> </ td> </ tr> </ table></p> <p>FOOTER.ASCX (Footer User Control)</p> <p><Script language = "c #" runat = "server"></p> <p>Private void Page_Load (Object SRC, Eventargs E)</p> <p>{</p> <p>IF (session ["username"]! = NULL)</p> <p>{</p> <p>LBlusername.text = (string) session ["username"];</p> <p>LBLPURVIEW.TEXT = (String) session ["purview"];</p> <p>}</p> <p>}</p> <p></ script></p> <p>Username: <asp: label id = "lblusername" font-name = "arial" forcolor = "red" text = "Visitor" runat = "server" /></p> <p>Permissions: <asp: label id = "lblpurview" font-name = "arial" text = "None" forcolor = "red" runat = "server" /></p> <p>Each control contains its own display code and the corresponding program code.</p> <p>We can make some common functions into fixed user controls. When we need it, we can use it directly, do not need to use annoying CRTL C, Ctrl V to "copy", "paste" long A large pile of code.</p> <p>The user control not only did the separation of the program code and the page frame, but also added code reuse.</p> <p>3 Custom Control (Custom Control)</p> <p>User control is a very good choice, but since each user control is an ASCX file, when these controls are much more, they are more zero. At this point we want to integrate some more similar controls, just quote once in the program, all get it all. This is a very good idea, we have made this idea more professional: "Import multiple classes into the same namespace (Namespace". Oh, how is this sentence, is it a bit familiar? Everyone goes to check the definition of the Server control, is it to find this sentence ...</p> <p>Let's take a look at how to write a Server control. Write a Server control is not a relaxed and easy thing, you need to have a deep understanding of the .NET platform, suitable for advanced users, so I don't specifically describe the preparation steps of the Server control (to be detained, not to write The book is not available). Please compare the difference between custom control source code and user controls, do some roughly understanding:</p> <p>Using system;</p> <p>Using system.data;</p> <p>Using system.data.sqlclient;</p> <p>Using system.drawing;</p> <p>Using system.Web;</p> <p>Using system.Web.ui;</p> <p>Using system.Web.ui.webcontrols;</p> <p>Namespace ASPCN</p> <p>{</p> <p>// First, HeaderPublic Class Header: Control, InamingContainer</p> <p>{</p> <p>Private adrotator ad;</p> <p>Private label lbladtext;</p> <p>Protected Override Void CreateChildControls ()</p> <p>{</p> <p>/ / Add to ADROTATOR Advertising Control</p> <p>ad = new adjrotator ();</p> <p>Ad.advertisementfile = "adbanners / ad.xml";</p> <p>Ad. brorderwidth = 0;</p> <p>Ad.adcreated = New AdcreatedEventHandler (this.onadcreated);</p> <p>This.Controls.Add (ad);</p> <p>This.Controls.Add (New LiteralControl ("<br>" "The current ad link is:"));</p> <p>/ / Add to Label control</p> <p>LBLADTEXT = New label ();</p> <p>LBLADTEXT.FORECOLOR = color.red;</p> <p>This.Controls.add (lbladtext);</p> <p>}</p> <p>Private void onadcreated (Object Sender, AdcreatedEventArgs E)</p> <p>{</p> <p>this.lbladtext.text = E.ALTERNATEXT;</p> <p>}</p> <p>}</p> <p>/ / Next, Logon</p> <p>Public Class Logon: Control, InamingContainer</p> <p>{</p> <p>Private string strconnstring = "server = (local) / feidao; database = aspcn; trusted_connection = yes";</p> <p>Private label lblmsgshow;</p> <p>Private textbox tbusername, tbpasswd;</p> <p>Public String Username</p> <p>{</p> <p>get</p> <p>{</p> <p>Return TBUSERNAME.TEXT;</p> <p>}</p> <p>set</p> <p>{</p> <p>TBUSERNAME.TEXT = VALUE;</p> <p>}</p> <p>}</p> <p>Protected Override Void CreateChildControls ()</p> <p>{</p> <p>// Add HTML tag</p> <p>This.Controls.add ("<Table> <TR> <TD Colspan =" 2 "align =" center "> <b> login window </ b> </ td> </ tr> <TR> < Td colspan = "2" align = "center"> "));</p> <p>// Add MSGSHOW Label control</p> <p>LBLMSGSHOW = New label ();</p> <p>LBLMSGSHOW.FORECOLOR = Color.Red;</p> <p>This.Controls.Add (lblmsgshow);</p> <p>This.Controls.add (New LiteralControl ("</ TD> </ TR> <TD> <TD> User Name: </ TD> <TD>"));</p> <p>// Add UserName and Passwd TextBox control</p> <p>TBUSERNAME = New textbox ();</p> <p>This.Controls.add (tbusername);</p> <p>THISCONTROLS.ADD ("</ td> </ tr> <tr> <td> password: </ td> <td>"); tbpasswd = new textbox ();</p> <p>Tbpasswd.textmode = textboxmode.password;</p> <p>This.Controls.Add (Tbpasswd);</p> <p>THIS.CONTROLS.ADD (New LiteralControl ("</ TD> </ TR> <Tr> <TD>"));</p> <p>// Add btnsubmit button control</p> <p>Button btnsubmit = new button ();</p> <p>btnsubmit.text = "Log in";</p> <p>Btnsubmit.Click = new eventhandler (this.submit_click);</p> <p>This.Controls.Add (btnsubmit);</p> <p>THIS.CONTROLS.ADD (New LiteralControl ("</ TD> </ TR> </ Table>));</p> <p>}</p> <p>//</p> <p>Private Void Submit_Click (Object Sender, Eventargs E)</p> <p>{</p> <p>SqlConnection myconn = new sqlconnection (strConnString);</p> <p>Myconn.open ();</p> <p>String strusername, strpassword, strselect;</p> <p>Strusername = tbusername.text;</p> <p>Strpassword = tbpasswd.text;</p> <p>strSelect = "SELECT * from bbs_user where id = '" strusername "' and password = '" strpassword "";</p> <p>Sqlcommand mycomm = new sqlcommand (strsElect, myconn);</p> <p>SqlDataReader DR = mycomm.executeRead ();</p> <p>IF (Dr.Read ())</p> <p>{</p> <p>//Landed successfully</p> <p>THIS.LBLMSGSHOW.TEXT = "Login Success";</p> <p>}</p> <p>Else</p> <p>{</p> <p>// Landing unsuccessful</p> <p>THIS.LBLMSGSHOW.TEXT = "Landing is not successful";</p> <p>}</p> <p>Dr.close ();</p> <p>MyConn.close ();</p> <p>}</p> <p>}</p> <p>// Finally Footer</p> <p>Public Class Footer: Control, InamingContainer</p> <p>{</p> <p>Private string _username, _purview;</p> <p>Public String Username</p> <p>{</p> <p>get</p> <p>{</p> <p>Return_username;</p> <p>}</p> <p>set</p> <p>{</p> <p>_USERNAME = VALUE;</p> <p>}</p> <p>}</p> <p>Public String Purview</p> <p>{</p> <p>get</p> <p>{</p> <p>Return_purview;</p> <p>}</p> <p>set</p> <p>{</p> <p>_PURVIEW = Value;</p> <p>}</p> <p>}</p> <p>Public footer () PUBLIC FOOTER ()</p> <p>{</p> <p>_USERNAME = "Tourists";</p> <p>_PURVIEW = "None";</p> <p>}</p> <p>Protected Override Void CreateChildControls ()</p> <p>{</p> <p>This.Controls.Add ("User Name:")); label lblusername = new label ();</p> <p>LBlusername.forecolor = color.red;</p> <p>lblusername.font.name = "arial";</p> <p>LBlusername.text = this.username;</p> <p>This.Controls.add (lblusername);</p> <p>//this.controls.add(new LitralControl ("NBSP;"));</p> <p>THIS.CONTROLS.ADD (New LiteralControl);</p> <p>Label lblpurview = new label ();</p> <p>LBLPURVIEW.FORECOLOR = Color.Red;</p> <p>LBLPURVIEW.FONT.NAME = "arial";</p> <p>LBLPURVIEW.TEXT = this.purview;</p> <p>This.Controls.Add (lblpurview);</p> <p>}</p> <p>}</p> <p>}</p> <p>The above and programs are the functions that will need to be implemented, all imported custom controls. As can be seen in the program, three classes are included in the ASPCN namespace, which is the three main part of the architecture.</p> <p>To use a custom control, you must also compile the original code.</p> <p>CSC / T: library /out:aspcn.dll /r:system.data.dll ,system.web.dll ,system.drawing.dll CustomControls.cs</p> <p>The use of C # program compiles instructions, I will not repeat it here. It should be noted that the compiled file name must be consistent with the name of Namespace in the control.</p> <p>Compiled DLL still can't be used, we must put it in the most famous directory in the .NET platform - BIN directory (if you do not exist, you can build it yourself) is stored in the current virtual directory. Define controls and components, CLR automatically searches files in this directory when performing an ASP.NET program to find Namespace, Class, and Assembly matching the ASP.NET program.</p> <p>When we use the program compiled aspcn.dll to put the / bin directory, this SERVER control you write can be used.</p> <p>(Need to declare that SESSION variables cannot be used when writing Server controls, so that the communication between the two CLASs cannot be done, the FOOTER control is not like the previous program, but the SESSION content is changed as the previous program. You can operate the corresponding property by normal operation of the SERVER control method.</p> <p>Let's take a look at the program content of the main web form:</p> <p><% @ Register tagprefix = "aspcn" namespace = "aspcn" askMBLY = "aspcn"%></p> <p><html></p> <p><HEAD></p> <p><title> </ title></p> <p></ hEAD></p> <p><body></p> <p><form runat = "server"></p> <p><aspcn: header id = "myHeader" runat = "server" /></p> <p><aspcn: logon ID = "MYLOGON" runat = "server" /> <aspcn: footer id = "myfooter" runat = "server" /></p> <p></ form></p> <p></ body></p> <p></ html></p> <p>How is it, it's quite simple.</p> <p>Quite a custom control, it is quite simple, just set all the TagPrefix, Namespace of the Register directive, and the assembly property are all set to ASPCN.</p> <p>At this point, the three types of code in ASP.NET and the page architecture have been introduced.</p> <p>The three methods have advantages and disadvantages, I am more preferred to use the user control to combine with CodeBinde technology because they don't need to be compiled, relatively easy to use, if you want to protect your code, custom control is of course you best choice.</p> <p>I hope this article is helpful to your programming.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-79233.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="79233" 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.038</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 = 'QhcrKrWWrS1WnI5ih9WnlaqWDoJAzhvg447_2Bb6J1qje7A20GLN9XE_2FJj0IXuHpee6qbSc1ksMNwBhNXMuC7hAw_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>