1. Select the HTML prototype webpage on the homepage
Then add some special tokens to the HTML webpage, so that the system can perform operations more accurately when the page is static!
2. Get HTML webpageCode
I chose to use the fileupload control to obtain the static attitude page model and save it!
Copy code The Code is as follows: if (fileupload1.postedfile. filename = "")
{
Response. Write ("<SCRIPT> alert ('Are you sure you have selected a webpage? ') </SCRIPT> ");
Return;
}
If (fileupload1.filename. lastindexof (".")! = "Htm") | (fileupload1.filename. lastindexof (".")! = "Html "))
{
Response. Write ("<SCRIPT> alert ('Are you sure you have selected a webpage? ') </SCRIPT> ");
Return;
}
System. Text. Encoding EC = system. Text. encoding. getencoding ("gb2312"); // specify the encoding format
System. Io. streamreader sr = new system. Io. streamreader (fileupload1.postedfile. filename, EC );
String strhtml = 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>
/// Formatted HTML
/// </Summary>
/// <Param name = "str"> </param>
/// <Returns> </returns>
Private string formatstr (string Str)
{
String strcontent = Str. Replace ("<", "<");
Strcontent = strcontent. Replace (">", "> ");
// Strcontent = strcontent. Replace (CHR (13), "<br> ");
Strcontent = strcontent. Replace ("\ r", "<br> ");
Strcontent = strcontent. Replace ("","");
Strcontent = strcontent. Replace ("[isok]", "Strcontent = strcontent. Replace ("[B]", "<B> ");
Strcontent = strcontent. Replace ("[Red]", "<font color = cc0000> ");
Strcontent = strcontent. Replace ("[Big]", "<font size = 7> ");
Strcontent = strcontent. Replace ("[/isok]", "> </img> ");
Strcontent = strcontent. Replace ("[/B]", "</B> ");
Strcontent = strcontent. Replace ("[/Red]", "</font> ");
Strcontent = strcontent. Replace ("[/big]", "</font> ");
Return strcontent;
}
3. Extract the previously saved HTML page model
Then use string. Replace (char oldstring, char newstring );
Replace the pre-configured special tags on the model page with the ones we need to change dynamically!
4. Save the dynamically updated HTML code files, and store the paths as databases for ease of calling.