Skip to content Skip to sidebar Skip to footer

ASP.NET C# Properly Generating HTML For Page

I realize this is probably a fundamental thing I should know but I am self-teaching myself C# and asp.net so I am a little lost at this point. I right now have 2 pages. One is an

Solution 1:

I think you need to read up on some basic ASP.Net documentation and tutorials. Response.Write is not the correct approach - you need to understand how the ASP.Net page lifecycle works and how WebControls are used to render the html.

ASP.Net tries to abstract away having to create your html manually for the most part.


Solution 2:

So if i have understood the questions correctly. You already have an existing page/application (the shtml file) that you want to extend with some new ASP.NET components by including output from the ASP.NET page in the existing page?

This is as not something that is out of the box "supported" by ASP.NET and you "won't" be able to execute the aspx page using SSI. But you can do the opposite, an ASP.NET page does support SSI. So if you are not using any other scripts in the shtml file this might be a solution.

Otherwise the only common solutions would be either to use an AJAX framework and let it call the ASP.NET from within the existing pages or to use an iframe solution. In both cases the client will be resposible for making the calls to the ASP.NET pages and merging the results.

And then you have a issue with controlling the output from the ASP.NET page?

The Polymorphic Podcast has a good article on Controlling HTML in ASP.NET WebForms .


Solution 3:

You can add a Literal control to the page inside the div:

<div>
   <asp:Literal ID="litMarkup" runat=server />
</div>

then in your code-behind:

litMarkup.Text = "<strong>Your markup</strong>";

Solution 4:

I don't know how well this would work for you, but could you try using an iframe to house the ASP.NET page? This should keep it in the specified region and not overwriting your shtml file. It may be something to think about.


Post a Comment for "ASP.NET C# Properly Generating HTML For Page"