Petelai project experience collection (6) ___ ASP. NET template page reading, petelai ___ asp.net

Source: Internet
Author: User

Petelai project experience collection (6) ___ ASP. NET template page reading, petelai ___ asp.net

In the PERT after-sales management system process, one of the nodes is fault analysis, that is, fault analysis is performed on the whole machine that is sent back, the traditional method is to input the fault information of each machine into an Excel table. The Excel format is as follows:

 

Here is to convert Excel to a template page, and then replace the tags in the template as needed to display the functions completely. The following describes how to implement this function in the project:

1. Convert Excel to Web Page

Open the Excel document, click "file" in the menu bar, and find "Save ",. In the "Save as" window, click "Save type" and select "single file webpage" from the drop-down menu ". Name.

 

2. Modify the template page

Let's take a look at the static template page (htm page) generated at the header and tail of the template in Excel. The # part of the page is the tag to be replaced:

Let's take a look at the implementation of this part of Code. These are simple HTML code. The webpage code converted from EXCEL is slightly modified:

<Body style = "width: 95%; margin: 0 auto; padding: 20px; "> <form name =" form "method =" post "action =" # "> [# ChaiFenID #] <table border =" 1px "style =" border-collapse: collapse; "> <tr style =" text-align: center; "> <td colspan =" 15 "class =" style1 "> fault analysis table for starters (class) </td> </tr> <td colspan = "2" class = "style2"> two-dimensional factory </td> <td colspan = "5" class =" style3 "> [# CCEWM #] </td> <td colspan =" 3 "class =" style2 "> aftersales QR code </td> <Td colspan = "5" class = "style3"> [# SHEWM #] </td> </tr> <td rowspan = "2" class =" style5 "> Information </td> <td class =" style6 "> Feedback Unit </td> <td colspan =" 3 "class =" style7 "> [# FKDW #] </td> <td class = "style6"> feedback date </td> <td colspan = "2" class = "style7"> [# FKRQ #] </td> <td class = "style5"> Model </td> <td colspan = "2" class = "style7"> [# XH #] </td> <td class =" style5 "> serial number </td> <td colspan =" 3 "class =" style7 "> [# XLH #] </Td> </tr> <td class = "style6"> three-pack server </td> <td class = "style5"> [# SBJ #] </td> <td class = "style6"> 0 km host </td> <td class = "style6"> appearance photos </td> <td colspan = "5" class = "style8"> </td> <td colspan = "3" class = "style5"> Performance </td> <td colspan = "2" class = "style10"> <input id = "Radio1" type = "radio" name = "yes" value = "yes"/> Yes <input id = "Radio2" type = "radio" valule = "No"/> NO </td> </tr> <td class = "style5"> Fault <br/> component </td> <td class = "style6"> fault symptom </td> <td class = "style5"> fault <br/> symptom </ td> <td class = "style6"> fault symptom </td> <td class = "style5"> fault <br/> symptom </td> <td class = "style6 "> fault symptom </td> <td class =" style5 "> fault <br/> symptom </td> <td class =" style6 "> fault symptom </td> <td class = "style5"> fault <br/> symptom </td> <td class = "style6"> fault symptom </td> <td class = "style5"> fault <br/> symptom </td> <td class = "style6"> fault symptom </td> <td cl Ass = "style5"> fault <br/> symptom </td> <td class = "style6"> fault symptom </td> <td class = "style5"> fault <br/> symptom </td> </tr> [# Body #] <tr> <td rowspan = "2" class = "style5"> others <br/> J </td> <td class = "style4"> 1. User disintegration </td> <td class = "style5"> </td> <td colspan = "2" class =" style4 "> remarks for missing parts </td> <td class =" style4 "> 2 foreign objects </td> <td class =" style5 "> </td> <td colspan = "2" class = "style4"> what foreign body to note </td> <td class = "style4"> 3. Dust </Td> <td class = "style5"> </td> <td class = "style4"> 4. influent </td> <td class = "style5"> </ td> <td class = "style4"> 5 oil intake </td> <td class = "style5"> </td> </tr> <td class =" style4 "> 6. incorrect installation </td> <td class =" style5 "> </td> <td colspan =" 2 "class =" style5 "> </td> <td class = "style4"> 7-pin disconnection </td> <td class = "style5"> </td> <td class = "style4"> 8 complete machine corrosion </td> <td class = "style5"> </td> <td class = "style4"> </td> <td class = "Style5"> </td> <td class = "style4"> </td> <td class = "style5"> </td> <td class = "style5"> </td> <td class = "style5"> </td> </tr> <td class = "style5"> remarks <br/> K </td> <td class = "style4"> 1 </td> <td class = "style5"> </td> <td class = "style4"> 2 </td> <td class = "style5"> </td> <td class = "style4"> 3 </td> <td class = "style5"> </td> <td class = "style4"> 4 </td> <td class = "style5"> </td> <td class = "style 4 "> 5 </td> <td class =" style5 "> </td> <td class =" style4 "> 6 </td> <td class =" style5"> </td> <td class = "style4"> 7 </td> <td class = "style5"> </td> </tr> <td colspan = "15" class = "style11"> note: please "√" in the space after the corresponding fault phenomenon. If there is a photo archive for the fault of the parts, please use a circle to show the front digit number. </Td> </tr> <td class = "style5"> </td> <td colspan = "2" class = "style12"> ANALYST: </td> <td colspan = "4" class = "style12"> </td> <td class = "style12"> </td> <td colspan = "3" class = "style12"> Analysis Date: </td> <td colspan = "3" class = "style12"> </td> <td class = "style12"> </td> </tr> </table> <input type = "button" name = "query" onclick = "return doSubmit (); "language =" javascript "value =" Submit "/> </form> </body>


 

3. ASP. NET read template page

ASP. NET:

String mbPath = Server. mapPath ("FaultMangaeTemplate.htm"); // template page Encoding code = Encoding. getEncoding ("gb2312"); // character encoding StreamReader sr = null; string str = null; // read try {sr = new StreamReader (mbPath, code); str = sr. readToEnd (); str = str. replace ("[# Body #]", tableBody); // Replace method, Replace the tag str = str in the template. replace ("[# FKDW #]", enWXJD. DLSName); str = str. replace ("[# FKRQ #]", enWXJD. DDDate); str = str. replace ("[# XH #]", ljxh); str = str. replace ("[# ChaiFenID #]", "<input id = \" hidChaifenID \ "type = \" hidden \ "value = \" "+ chaifenid +" \ "/>"); str = str. replace ("[# SBJ #]", "yes");} catch (Exception ex) {throw ex;} finally {sr. close ();} Response. clear (); Response. write (str); Response. end ();


 

The template generated above contains some tags. Let's take a look at the html code for replacing the tags of the Subject Part of the page:

/// <Summary> /// combine the fault information of faulty parts and parts to generate html /// </summary> private string bindGZJBJXX () {string strHTML = ""; dataTable dtGZBJ = new BT_LJGZ_GZManage (). queryAllGZBJByGZZL ("starter"); for (int I = 0; I <dtGZBJ. rows. count; I ++) {if (I = 0) {strHTML = "<tr> <td class = \" style5 \"";} else {strHTML + = "<tr> <td class = \" style5 \ "";} strHTML + = "rowspan = \" "; DataTable dtGZXX = new BT_LJGZ_GZManage (). queryAllGZX XByGZBJ (Convert. toInt32 (dtGZBJ. rows [I] ["ID"]); double rowspan = Math. ceiling (double) dtGZXX. rows. count/(double) 7); // each line displays 7 fault information strHTML + = Convert. toString (rowspan); strHTML + = "\"> "; strHTML + = Convert. toString (dtGZBJ. rows [I] ["GZBJ"]); strHTML + = "</td>"; for (int j = 0; j <dtGZXX. rows. count; j = j + 7) {if (j % 7 = 0) {if (j! = 0) {strHTML + = "<tr>" ;}for (int z = j; z <j + 7; z ++) {if (z <dtGZXX. rows. count) {strHTML + = "<td class = \" style4 \ ">"; strHTML + = Convert. toString (dtGZXX. rows [z] ["GZMC"]); strHTML + = "</td>"; strHTML + = "<td class = \" style5 \ "> "; strHTML + = "<input value = \" "+ dtGZXX. rows [z] ["ID"]. toString () + "\" "; strHTML + =" name = \ "input \" type = \ "checkbox \"/> "; strHTML + = "</td>";} else {strHTML + = "<td class = \" style4 \ ">"; strHTML + = "</td> "; strHTML + = "<td class = \" style5 \ ">"; strHTML + = "</td> ";}} strHTML + = "</tr>" ;}} return strHTML ;}

The function implementation page is as follows:


This function is briefly introduced here. The reason why I wrote this blog is that the design and implementation of this function is the first time. I didn't know where to start when I started to implement this function, the discovery is actually quite simple. All the experience comes from experience. If there is more experience, there will be more experience!


The content on the ASPNET template page is blank.

Suggestions
1. aspx input word 1
2. aspx input 2

Check whether it has changed!

How does aspnet obtain the ID of a div using the template page javascript?

Document. getElementById ("warn;
But if you are an asp.net control, you have
Document. getElementById ("<% = Control name. ClientID> ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.