Skip Navigation Links


Convert .Net Source to HTML Source

Enter your ASP.Net Source




Converted Strings

Note:
*No more than 50 lines

Converting ASP.Net Source to HTML Source

A Convenient & Quick Codes to Convert ASP.Net to HTML

I started to post my ASP.Net related note here, and I was in need to copy past my ASP.Net code to my own blog input form. Converting "<" and ">" is a time consuming work. I have written a quick code to convert those 2 characters to be able to display as a HTML on web.

Here is how I wrote it. Working version is at http://asp.syantien.com/pgeConvertToHTMLSource01.aspx

<%@ Page Language="VB" 
MasterPageFile="~/MasterPageSub01.master" _
AutoEventWireup="false" _
CodeFile="pgeConvertToHTMLSource01.aspx.vb" _
Inherits="pgeConvertToHTMLSource01" _
ValidateRequest="false" _
Title="Convert .Net Source to HTML Srouce - ASP.Net n more" %>

<asp:Content ID="Content1" _
ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
    <h1>
        Convert .Net Source to HTML Source</h1>
    Enter your ASP.Net Source 
    <br />
    <asp:TextBox ID="txtSource" runat="server" _
TextMode="MultiLine" Width="90%" Height="250px"></asp:TextBox>
    <br />
    <asp:Label ID="lblError" runat="server" ForeColor="Red" />
    <br />
    <asp:Button ID="btnConvert" runat="server" Text="Convert" _
Width="90%" />
    <br /><br />
    Converted Strings
    <br />
    <asp:TextBox ID="txtResult" runat="server" _ 
TextMode="MultiLine" Width="90%" Height="250px"></asp:TextBox>
    <br />
    Note:
    <br />
    *No more than 50 lines
</asp:Content>

'======================
'Syantien, ASP.Net n More
'Convert (Replace) ASP.net Source to HTML Source
'asp.vb file
'======================
Partial Class pgeConvertToHTMLSource01
  Inherits System.Web.UI.Page

  Protected Sub btnConvert_Click(ByVal sender As Object, _ 
ByVal e As System.EventArgs) Handles btnConvert.Click
  
  'Put Limit on Size
  If txtSource.Rows <= 50 Then

    'Refresh
    lblError.Text = ""
    txtResult.Text = ""

    'Convert
    txtResult.Text = Replace(Replace(txtSource.Text, ">", _ 
"&gt;"), "<", "&lt;")

  Else
    'Display an error
    lblError.Text = "Too big, needs to be less than 50 lines, _ 
please try again."

  End If

  End Sub
End Class

Tag: Convert ASP.Net Code HTML Source
By: syantien | 9/2/2008 11:16:46 PM / 9/2/2008 11:34:09 PM

Comment


Name

Email

Comment


Your IP Address is:
* for the safety, we keep record of your ip address.
* all post must be approved before post, you may not see your post for a while I am busy.. (sorry)