2009-10-02 142 views
0

我目前正在嘗試使現有的ASP.NET WebForms應用程序使用Site.Master模板。正確使用母版頁和內容頁中的表格

創建Site.Master模板並不是一個真正的問題,因爲它就像一個魅力。

該問題從派生它並將控件放在給定的ContentPlaceHolder中開始。

在運行時,我收到以下錯誤消息:

Control 'ctr00_Login1' of type 'Login' must be placed inside a form tag with runat=server 

這來自我放在模板的Site.Master的LoginControl。

我應該如何處理這個錯誤以及在母版頁中使用元素的最佳做法是什麼?

在此先感謝您的幫助!

回答

3

看起來您的主頁上沒有表單元素(<form>)。在這裏閱讀到see how masterpages work

你應該有大致如下(從MSDN頁)線的東西:

<form id="form1" runat="server"> 
     <table> 
      <tr> 
       <td><asp:contentplaceholder id="Main" runat="server" /></td> 
       <td><asp:contentplaceholder id="Footer" runat="server" /></td> 
      </tr> 
     </table> 
    </form> 

無論是或登錄控制是不是<form>標籤內。

+0

此外,表單標籤應該從子頁面中刪除(或刪除runat =「server」部分)。 – 2009-10-02 15:01:33

+0

非常感謝!這個幫助我了!它分配給該表單的哪個id值是否重要? – 2009-10-02 19:21:30

相關問題