Is there a way to make an ASP.NET 2.0 page render only a fragment of a page?
In other words, instead of
<html><head></head><body><form id="(autogenerated runat="server" form)"><asp:Whatever page contents/></form></body><html>
I just want the
<asp:Whatever page contents/>
One thing I've tried is to create a page master that has the following:
protected override void Render( System.Web.UI.HtmlTextWriter writer ) {
if ( !this.DesignMode ) {
// Directly render the content, skipping the page itself (content form is the main <form id="ContentForm" runat="server"> form)
this.ContentForm.RenderControl( writer );
} else {
// Render everything to keep visual studio happy.
base.Render( writer );
}
}
This still renders the <form> and <input> tags, which I don't want.
<form name="aspnetForm" method="post" action="MyPage.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="(randomstring)" />
</div>...
Rendering the ContentPlaceHolder directly fails when the content contains some <asp:> elements.
Is there a better way?