How to Convert HTML to Aspx

Save

The best way to convert an HTML page to an ASPX page is to create the ASPX file and transfer the HTML text. ASPX files are specially coded pages that have specific syntax. Several distinguishable differences are in an ASPX page compared to HTML. Knowing these differences will help you convert an HTML page to an ASPX file.

  • Open Visual Studio and create a new web page in the works space. Creating a new web page in Visual Studio automatically adds some of the header code necessary for the compiler to run the page. For instance, in an ASPX file, the below code is the first line in every file:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="<codefilename.aspx.cs" Inherits="codefilename" %>

  • Copy HTML tags from the HTML page to the newly created ASPX page. The best way to copy tags is by copying the header tags first, then copying the tags within the body, then copy and Javascript code.

  • Insert "runat=server" in all tags that need to be used with the code-behind file. Using "runat=server" allows the ASPX compiler to use that tag in the code. For instance, if you need to use a text box in the ASPX code-behind to manipulate user input, the text box HTML tag needs "runat=server" inserted. Below is an example of an HTML tag with the "runat=server" inserted:
    <div runat="server" id="myDiv"></div>

  • Ensure tags with the "runat=server" inserted have an ID property assigned. Although this isn't necessary in HTML, an ASPX page needs ID properties assigned to use the elements in the code-behind file. Below is an example of a tag with an ID property:
    <div runat="server" id="myDiv">My Div</div>

  • Remove HTML form tags. When you create the ASPX page, you see a "form" tag automatically inserted. ASPX files have one form tag that envelopes all the code in the "body" tag. If you leave other "form" tags in the ASPX file, an error is returned.

  • Save the file and test it in the web browser. You can test an ASPX file using the internal Visual Studio browser. Right-click the page and select "Open in browser" to test the page.

References

Promoted By Zergnet

Comments

You May Also Like

  • How to Convert HTML to PDF in ASP.NET

    ASP.NET has thousands of native classes that perform a variety of functions (CE, see reference 2). PDF conversion is not one of...

  • How to Convert SPX to an MP3

    The SPX file extension corresponds to the Ogg Vorbis Speex file format, a repackaging of the regular Ogg Vorbis file format designed...

  • How do I Change ASPX Into a PDF?

    Developed by Microsoft, the .NET Framework gives programmers a set of languages and tools that help them create applications for desktop computers,...

  • HTML to XML Conversion Tools

    Although similar in appearance and function, Web-based HyperText Markup Language, or HTML is not the same as XML, or Extensible Markup Language....

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!