This might be a crazy question (I\'m somewhat new to ASP.NET). But is it possible to mix ASP.NET code with classic ASP e.g. embedded a form created in ASP.NET in a classic A
Generally, the answer to your question is no.
However, in some cases, it may be possible to render part of an ASP.net page and then place the result into an ASP page.
I experimented with that a little bit last week using AJAX.
Here's what you can do.
Let's suppose that you have an ASP.net page with a form in it that you would like to render on an ASP page.
1) Create the ASP.net page with the form and wrap it in an ASP:Panel - give it an id: pnlForm
2) In your ASP.net codebehind, write the following code in Page_Load
: pnlForm.RenderControl()
.
System.IO.StringWriter stringWriter = new System.IO.StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
pnlReport.RenderControl(htmlWriter);
Response.Write(stringWriter.ToString());
3) Add the following code snippet to the end of the codebehind:
// This snippet is neccessary to get ASP.net to render the report outsisde the page to write to an Excel spreadsheet.
public override void VerifyRenderingInServerForm(Control control)
{
return;
}
4) Create a blank div
in your classic ASP page - give it the ID formDiv
.
5) On the classic ASP page, use jQuery.ajax to fetch the form and place it on the classic ASP page:
$.ajax({
type: "GET",
url: "myASPdotNetpage.aspx",
success: function(response) { $('#formDiv').html(response); }
});
As you can imagine, this is not exactly how the framework is meant to be used, but if you really need to render some ASP.net and put it somewhere else (such as on an ASP page, or even a spreadsheet sometimes), you can at least capture the HTML.