dubloons
dubloons

Reputation: 1140

ASP.NET Master Page and User Content Forms

Is there a good way to enable forms that come out of user content (CMS) that is displayed inside the form runat="server" tag? All sorts of services provide forms for users to paste into their website, which break if the content ends up inside a .net form. It seems to me that there must be a good way around this, but I can't seem to find any solutions.

Upvotes: 2

Views: 464

Answers (1)

Keltex
Keltex

Reputation: 26446

The one solution I've found is to put them in an IFRAME. So instead of embedding your form inside the page:

<FORM action="http://www.example.com/target.html">
  .. form content
</FORM>

create a new ASPX file like this:

<FORM action="http://www.example.com/target.html" target="_top">
  .. form content
</FORM>

Then in your original page, you'll refer to it via an IFRAME:

<IFRAME src='myform.aspx'></IFRAME>

Some things you'll need to do:

  • Make sure that you do not include any <FORM runat="server"> inside the new ASPX file.
  • Adjust the size of the IFRAME and the ASPX file to be exactly the same
  • For the FORM in the new ASPX files, you probably want to set target='_top' to ensure when a user fills in the form, the result is in the main window rather than inside the IFRAME.

Upvotes: 2

Related Questions