0

尝试呈现我的转发器的 html 时,我收到表单标签错误(...必须放在带有 runat=server. 在 System.Web.UI.Page.VerifyRenderingInServerForm... 的表单标签内)。

渲染调用:

System.Text.StringBuilder stringbuilder = new System.Text.StringBuilder();
StringWriter stringwriter = new StringWriter(stringbuilder);
HtmlTextWriter htmltextwriter = new HtmlTextWriter(stringwriter);
rptEvaluation.RenderControl(htmltextwriter);//repeater control

content += stringbuilder.ToString(); //content is a string variable. 

没有渲染组件,页面和背后的代码可以正常工作。

有什么想法吗?

谢谢,亚当。这是我的中继器

<asp:Repeater ID="rptEvaluation" runat="server" OnItemDataBound="rptEvaluation_OnItemDataBound">
<HeaderTemplate>
<table>
<tr>
<th>Category Name</th>
</tr>
</HeaderTemplate>

<AlternatingItemTemplate>
<asp:HiddenField ID="hfCatID" runat="server" Value='<%#Eval("CategoryId") %>' />
<tr style="background-color:#eee;">
<td><%# DataBinder.Eval(Container.DataItem, "Category") %></td>
</tr>
<tr>
<td>
<asp:Repeater ID="rptCategoryQuestions" runat="server">
                    <HeaderTemplate>
                        <table>
                            <tr>
                            <th>Question ID</th>
                            <th>Question</th>
                            <th>Student score</th>
                            </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                    <asp:HiddenField ID="hfQuestID" runat="server" Value='<%#Eval("QuestionID") %>' />
                            <tr>
                                <td><%# DataBinder.Eval(Container.DataItem, "QuestionID") %></td>
                                <td><%# DataBinder.Eval(Container.DataItem, "Question") %></td>
                                <td>
                                    <asp:RadioButtonList ID="rblScore" runat="server">
                                        <asp:ListItem Text="Approaching" Value="1"></asp:ListItem>    
                                        <asp:ListItem Selected="True" Text="Meets" Value="2"></asp:ListItem>    
                                        <asp:ListItem Text="Exceeds" Value="3"></asp:ListItem>    
                                    </asp:RadioButtonList>
                               </td>
                            </tr>
                        </ItemTemplate>
                    <AlternatingItemTemplate>
                    <asp:HiddenField ID="hfQuestID" runat="server" Value='<%#Eval("QuestionID") %>' />
                            <tr>
                                <td><%# DataBinder.Eval(Container.DataItem, "QuestionID") %></td>
                                <td><%# DataBinder.Eval(Container.DataItem, "Question") %></td>
                                <td>
                                    <asp:RadioButtonList ID="rblScore" runat="server">
                                        <asp:ListItem Text="Approaching" Value="1"></asp:ListItem>    
                                        <asp:ListItem Selected="True" Text="Meets" Value="2"></asp:ListItem>    
                                        <asp:ListItem Text="Exceeds" Value="3"></asp:ListItem>    
                                    </asp:RadioButtonList>
                               </td>
                            </tr>
                     </AlternatingItemTemplate>
                    <FooterTemplate>
                        </table>
                    </FooterTemplate>
                </asp:Repeater>
            </td>
        </tr>
</AlternatingItemTemplate>

<ItemTemplate>
    <asp:HiddenField ID="hfCatID" runat="server" Value='<%#Eval("CategoryId") %>' />
        <tr style="background-color:#666;">
            <td><%# DataBinder.Eval(Container.DataItem, "Category") %></td>
        </tr>
        <tr>
            <td>
                <asp:Repeater ID="rptCategoryQuestions" runat="server">
                    <HeaderTemplate>
                        <table>
                            <tr>
                            <th>Question ID</th>
                            <th>Question</th>
                            <th>Student Score</th>
                            </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                    <asp:HiddenField ID="hfQuestID" runat="server" Value='<%#Eval("QuestionID") %>' />
                            <tr>
                                <td><%# DataBinder.Eval(Container.DataItem, "QuestionID") %></td>
                                <td><%# DataBinder.Eval(Container.DataItem, "Question") %></td>
                                <td>
                                    <asp:RadioButtonList ID="rblScore" runat="server">
                                        <asp:ListItem Text="Approaching" Value="1"></asp:ListItem>    
                                        <asp:ListItem Selected="True" Text="Meets" Value="2"></asp:ListItem>    
                                        <asp:ListItem Text="Exceeds" Value="3"></asp:ListItem>    
                                    </asp:RadioButtonList>
                               </td>
                            </tr>
                        </ItemTemplate>
                    <AlternatingItemTemplate>
                    <asp:HiddenField ID="hfQuestID" runat="server" Value='<%#Eval("QuestionID") %>' />
                            <tr>
                                <td><%# DataBinder.Eval(Container.DataItem, "QuestionID") %></td>
                                <td><%# DataBinder.Eval(Container.DataItem, "Question") %></td>
                                <td>
                                    <asp:RadioButtonList ID="rblScore" runat="server">
                                        <asp:ListItem Text="Approaching" Value="1"></asp:ListItem>    
                                        <asp:ListItem Selected="True" Text="Meets" Value="2"></asp:ListItem>    
                                        <asp:ListItem Text="Exceeds" Value="3"></asp:ListItem>    
                                    </asp:RadioButtonList>
                               </td>
                            </tr>
                     </AlternatingItemTemplate>
                    <FooterTemplate>
                        </table>
                    </FooterTemplate>
                </asp:Repeater>
            </td>
        </tr>
    </ItemTemplate>
<FooterTemplate>
     </table>
</FooterTemplate>

'

4

0 回答 0