Question

I have to add simple form to a asp:PlaceHolder

<form action="https://www...." method="post" target="_top">
<input type="hidden"...
<input type="hidden"...
<input type="image" ...name="submit">
</form>

In PageLoad() I added:

data = "<form action=...."
this.myPlaceHolder.Controls.Add(new LiteralControl(data));

When page rendered page source is:

<input type="hidden"...
<input type="hidden"...
<input type="image"...name="submit"...
<img alt=""...

As you can see no form tag? But I am sure that data variable contains "<form ...". Is there any other way to add form to placeholder maybe I use wrong approach?

Was it helpful?

Solution

I have to add this answer maybe will help someone.
When I add "<form..." form tag is not added but
If I add "<form></form><form..." to palceholder then it works.
I don't understand why but it works fine.

OTHER TIPS

instead of adding a form dynamically you should add those to the asp file. like this:

<form action="https://www" method="post" target="_top">
   <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
   </asp:ContentPlaceHolder>
</form>

then you can add any object on the placeholder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top