abdujalil  chuliev

abdujalil chuliev

  • NA
  • 400
  • 41.2k

Convert c# HtmlTextWriter page into simple asp.net

Sep 5 2017 2:40 AM
Hi, I got an old web page which is written using HtmlTextWriter.
I have some problems to control it. So I wanted to convert that into simple asp.net page.
What is the way to do so? Below is my code:
  1. <%@ Page Language="C#" %>  
  2.   
  3. <%@ Import Namespace="System.IO" %>  
  4. <%@ Import Namespace="System.Data" %>  
  5. <%@ Import Namespace="System.Data.SqlClient" %>  
  6.   
  7. <script language="C#" runat="server">  
  8.     protected override void Render(HtmlTextWriter writer)  
  9.     {  
  10.         Response.Buffer = true;  
  11.         Response.ContentEncoding = Encoding.UTF8;  
  12.   
  13.         String number_appl = "20170001";  
  14.         String objIntel = "marks";  
  15.         String username;  
  16.         username = User.Identity.Name;  
  17.   
  18.         writer.WriteFullBeginTag("html");  
  19.         writer.WriteLine();  
  20.   
  21.         writer.WriteBeginTag("meta");  
  22.         writer.WriteAttribute("http-equiv""Content-Type");  
  23.         writer.WriteAttribute("content""text/html; charset=utf-8");  
  24.         writer.Write(HtmlTextWriter.TagRightChar);  
  25.         writer.WriteLine();  
  26.   
  27.         writer.WriteBeginTag("xml");  
  28.         writer.WriteAttribute("id""template");  
  29.         writer.WriteAttribute("src""/edit/source.aspx?objIntel=" + objIntel + "&filename=template.xml&un=");  
  30.         writer.Write(HtmlTextWriter.TagRightChar);  
  31.         writer.WriteEndTag("xml");  
  32.         writer.WriteLine();  
  33.   
  34.         writer.WriteBeginTag("xml");  
  35.         writer.WriteAttribute("id""data");  
  36.         writer.WriteAttribute("src""/edit/source.aspx?objIntel=DataBase\\" + objIntel + "&filename=\\xmls\\" + number_appl + ".xml&un=" + username);  
  37.         writer.Write(HtmlTextWriter.TagRightChar);  
  38.         writer.WriteEndTag("xml");  
  39.         writer.WriteLine();  
  40.          
  41.         writer.WriteBeginTag("xml");  
  42.         writer.WriteAttribute("id""style");  
  43.         writer.WriteAttribute("src""/edit/source.aspx?objIntel=" + objIntel + "&filename=b7b.xsl&un=" + username);  
  44.         writer.Write(HtmlTextWriter.TagRightChar);  
  45.         writer.WriteEndTag("xml");  
  46.         writer.WriteLine();  
  47.   
  48.         writer.WriteBeginTag("xml");  
  49.         writer.WriteAttribute("id""xmlerror");  
  50.         writer.Write(HtmlTextWriter.TagRightChar);  
  51.         writer.WriteBeginTag("XMLDATA");  
  52.         writer.Write(HtmlTextWriter.TagRightChar);  
  53.         writer.WriteEndTag("XMLDATA");  
  54.         writer.WriteEndTag("xml");  
  55.         writer.WriteLine();  
  56.   
  57.         writer.WriteBeginTag("LINK");  
  58.         writer.WriteAttribute("REL""STYLESHEET");  
  59.         writer.WriteAttribute("HREF""/edit/styles.css");  
  60.         writer.Write(HtmlTextWriter.TagRightChar);  
  61.         writer.WriteEndTag("LINK");  
  62.         writer.WriteLine();  
  63.   
  64.         writer.WriteBeginTag("script");  
  65.         writer.WriteAttribute("language""JScript");  
  66.         writer.WriteAttribute("src""/edit/source.aspx?objIntel=" + objIntel + "&filename=showxml.js");  
  67.         writer.Write(HtmlTextWriter.TagRightChar);  
  68.         writer.WriteEndTag("script");  
  69.         writer.WriteLine();  
  70.         writer.WriteBeginTag("TITLE");  
  71.         writer.Write(HtmlTextWriter.TagRightChar);  
  72.         writer.Write(number_appl);  
  73.         writer.WriteEndTag("TITLE");  
  74.         writer.WriteLine();  
  75.   
  76.         writer.WriteBeginTag("body");  
  77.         writer.WriteAttribute("alink""#006666");  
  78.         writer.WriteAttribute("Link""#006666");  
  79.         writer.WriteAttribute("Vlink""#006666");  
  80.         writer.WriteAttribute("bgcolor""#f0fff0");  
  81.         writer.Write(HtmlTextWriter.TagRightChar);  
  82.         writer.WriteLine();  
  83.   
  84.         writer.WriteBeginTag("DIV");  
  85.         writer.WriteAttribute("id""showResult");  
  86.         writer.Write(HtmlTextWriter.TagRightChar);  
  87.         writer.WriteEndTag("DIV");  
  88.         writer.WriteLine();  
  89.                  
  90.         writer.WriteBeginTag("FORM");  
  91.         writer.WriteAttribute("ENCTYPE=""multipart/form-data");  
  92.         writer.WriteAttribute("action""savexml.aspx?un=" + username);  
  93.         writer.WriteAttribute("method""POST");  
  94.           
  95.         writer.WriteAttribute("name""FORM1");  
  96.         writer.Write(HtmlTextWriter.TagRightChar);  
  97.         writer.WriteBeginTag("INPUT");  
  98.         writer.WriteAttribute("type""submit");  
  99.         writer.WriteAttribute("name""Enter");  
  100.         writer.WriteAttribute("value""????????????? ?????????");  
  101.         writer.WriteAttribute("onClick""achSendDataToServer()");  
  102.         writer.WriteEndTag("INPUT");  
  103.         writer.WriteBeginTag("INPUT");  
  104.         writer.WriteAttribute("type""hidden");  
  105.         writer.WriteAttribute("name""blob");  
  106.         writer.WriteAttribute("value""blob_xml");  
  107.         writer.Write(HtmlTextWriter.TagRightChar);  
  108.         writer.WriteEndTag("INPUT");  
  109.         writer.WriteBeginTag("INPUT");  
  110.         writer.WriteAttribute("type""hidden");  
  111.         writer.WriteAttribute("name""appl_number");  
  112.         writer.WriteAttribute("value", number_appl);  
  113.         writer.Write(HtmlTextWriter.TagRightChar);  
  114.         writer.WriteEndTag("INPUT");  
  115.         writer.WriteBeginTag("INPUT");  
  116.         writer.WriteAttribute("type""hidden");  
  117.         writer.WriteAttribute("name""vid");  
  118.         writer.WriteAttribute("value", objIntel);  
  119.         writer.Write(HtmlTextWriter.TagRightChar);  
  120.         writer.WriteEndTag("INPUT");  
  121.         writer.WriteBeginTag("INPUT");  
  122.         writer.WriteAttribute("type""hidden");  
  123.         writer.WriteAttribute("name""un");  
  124.         writer.WriteAttribute("value", username);  
  125.         writer.Write(HtmlTextWriter.TagRightChar);  
  126.         writer.WriteEndTag("INPUT");  
  127.         writer.WriteEndTag("FORM");  
  128.         writer.WriteLine();  
  129.   
  130.         writer.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?> <user name=\"u_name\"> </user>");  
  131.           
  132.   
  133.         writer.WriteEndTag("body");  
  134.         writer.WriteLine();  
  135.         writer.WriteEndTag("html");  
  136.   
  137.     }  
  138.   
  139. </script>  
 

Answers (2)