Relationship between ASP. NET and HTML pages

Source: Internet
Author: User

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!

 
 
  1. If (FileUpload1.PostedFile. FileName= "")
  2. {
  3. Response. Write ("<Script>Alert ('Are you sure you have selected the website ')</Script>");
  4. Return;
  5.  
  6. }
  7. If (FileUpload1.FileName. LastIndexOf (".")! = "Htm") |
    (FileUpload1.FileName. LastIndexOf (".")! = "Html "))
  8. {
  9. Response. Write ("<Script>Alert ('Are you sure you have selected the website ')</Script>");
  10. Return;
  11. }
  12. SystemSystem. Text. Encodingec= System. Text. Encoding. GetEncoding ("gb2312"); // specify the Encoding format
  13. System. IO. StreamReadersr=NewSystem. IO. StreamReader (FileUpload1.PostedFile. FileName, ec );
  14.  
  15. StringstrHTML=Convert. ToString (sr. ReadToEnd ());
  16. StrHTML=FormatStr(StrHTML); // After formatting the HTML code, insert the strHTML into the database and extract it when it is ready for use!
  17. Sr. Close ();
  18. // Paste the HTML method code
  19.  
  20. ///<Summary> 
  21. /// Format HTML
  22. ///</Summary> 
  23. ///<ParamnameParamname="Str"></Param> 
  24. ///<Returns></Returns> 
  25. PrivatestringFormatStr (stringstr)
  26. {
  27. StrStringstrContent= Str. Replace ("<","& Lt;");
  28. StrContentStrContent= StrContent. Replace (">","& Gt;");
  29. //StrContentStrContent= StrContent. Replace (chr (13 ),"<Br>");
  30. StrContentStrContent= StrContent. Replace ("\ r ","<Br>");
  31. StrContentStrContent= StrContent. Replace ("", "& nbsp ;");
  32.  
  33. StrContentStrContent= StrContent. Replace ("[isOK]","<ImgsrcImgsrc= ");
  34. StrContentStrContent= StrContent. Replace ("[B]","<B>");
  35. StrContentStrContent= StrContent. Replace ("[red]","<FontcolorFontcolor=CC0000>");
  36. StrContentStrContent= StrContent. Replace ("[big]","<FontsizeFontsize=7>");
  37. StrContentStrContent= StrContent. Replace ("[/isOK]","></Img>");
  38. StrContentStrContent= StrContent. Replace ("[/B]","</B>");
  39. StrContentStrContent= StrContent. Replace ("[/red]","</Font>");
  40. StrContentStrContent= StrContent. Replace ("[/big]","</Font>");
  41. ReturnstrContent;
  42. }


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!

  1. Implementation of ASP. NET plug-in
  2. Overview ASP. NET Applications
  3. Introduction to ASP. NET 2.0 Data Binding
  4. ASP. NET prevents Java Script Injection attacks
  5. ASP. net mvc using T4

Related Article

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.