1. ASP. NET select HTML page
Then add some special tokens on the HTML page, so that the system can perform operations more accurately when the page is static!
2. ASP. net to get html page code
I chose to use the FileUpload control to obtain the static attitude page model and save it!
- If (FileUpload1.PostedFile. FileName= "")
- {
- Response. Write ("<Script>Alert ('Are you sure you have selected the website ')</Script>");
- Return;
-
- }
- If (FileUpload1.FileName. LastIndexOf (".")! = "Htm") |
(FileUpload1.FileName. LastIndexOf (".")! = "Html "))
- {
- Response. Write ("<Script>Alert ('Are you sure you have selected the website ')</Script>");
- Return;
- }
- SystemSystem. Text. Encodingec= System. Text. Encoding. GetEncoding ("gb2312"); // specify the Encoding format
- System. IO. StreamReadersr=NewSystem. IO. StreamReader (FileUpload1.PostedFile. FileName, ec );
-
- StringstrHTML=Convert. ToString (sr. ReadToEnd ());
- StrHTML=FormatStr(StrHTML); // After formatting the HTML code, insert the strHTML into the database and extract it when it is ready for use!
- Sr. Close ();
- // Paste the HTML method code
-
- ///<Summary>
- /// Format HTML
- ///</Summary>
- ///<ParamnameParamname="Str"></Param>
- ///<Returns></Returns>
- PrivatestringFormatStr (stringstr)
- {
- StrStringstrContent= Str. Replace ("<","& Lt;");
- StrContentStrContent= StrContent. Replace (">","& Gt;");
- //StrContentStrContent= StrContent. Replace (chr (13 ),"<Br>");
- StrContentStrContent= StrContent. Replace ("\ r ","<Br>");
- StrContentStrContent= StrContent. Replace ("", "& nbsp ;");
-
- StrContentStrContent= StrContent. Replace ("[isOK]","<ImgsrcImgsrc= ");
- StrContentStrContent= StrContent. Replace ("[B]","<B>");
- StrContentStrContent= StrContent. Replace ("[red]","<FontcolorFontcolor=CC0000>");
- StrContentStrContent= StrContent. Replace ("[big]","<FontsizeFontsize=7>");
- StrContentStrContent= StrContent. Replace ("[/isOK]","></Img>");
- StrContentStrContent= StrContent. Replace ("[/B]","</B>");
- StrContentStrContent= StrContent. Replace ("[/red]","</Font>");
- StrContentStrContent= StrContent. Replace ("[/big]","</Font>");
- ReturnstrContent;
- }
3. ASP. NET extract the HTML page model previously saved
Then use string. Replace (char oldstring, char newstring );
Replace the pre-configured special tags in the page model with the ones we need to change dynamically!
4. Save the dynamically updated HTML code files and save the paths as databases for convenient calling!
- Implementation of ASP. NET plug-in
- Overview ASP. NET Applications
- Introduction to ASP. NET 2.0 Data Binding
- ASP. NET prevents Java Script Injection attacks
- ASP. net mvc using T4