2013-04-22 40 views
0

我要簡單的形式添加到ASP:佔位符如何html表單添加到ASP:佔位符(缺少表單標籤)

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

PageLoad()我說:

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

當頁面呈現頁面的源代碼是:

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

正如你可以看到沒有表單標籤? 但我確定data變量包含「<form ...」。 有沒有其他的方式來添加表格到placeholder也許我使用錯誤的方法?

+0

你不能編輯.aspx文件嗎? – Curt 2013-04-22 11:30:44

+0

不,我必須添加這個表單動態 – 1110 2013-04-22 11:31:15

+0

直接使用Literal來添加表單,以及其餘的數據。 – Aristos 2013-04-22 11:35:06

回答

1

我必須添加此答案也許會幫助某人。
當我添加「<form...」表格標籤沒有添加,但
如果我添加「<form></form><form...」給palceholder然後它的工作。
我不明白爲什麼,但它工作正常。

0

而不是動態添加表單,您應該將這些添加到asp文件。像這樣:

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

然後你可以在佔位符上添加任何對象。