在ASP.NET Databound Formview中允许HTML输入

时间:2013-07-30 18:26:54

标签: asp.net

我有一个ASP:Formview,它被数据绑定到LINQDatasource,我的一个字段需要允许HTML。 (它存储在数据库中,用于在另一个网页上动态显示格式化文本,这就是我的客户编辑它的方式)

奇怪的行为是因为它是数据绑定,更新数据是很好的,并且HTML标记没有问题。但是,当我使用formview取消按钮时,它会引发抱怨标签的“危险文本”错误。我已阅读并阅读有关此内容并查看“关闭页面验证”和“使用Javascript对文本进行编码”的常用答案,但这些对我不起作用,因为;

将requestValidaitonMode =“2.0”添加到我的web配置并将Pagevalidation = false添加到我的页面属性不能解决问题我无法使用javascript,因为它的数据绑定到LINQdatasource所以它在其中完成所有提交工作黑匣子。

我有什么选择?

CODE:

<asp:LinqDataSource ID="BoardDetails_LDS" runat="server" ContextTypeName="Boards_and_Commisions_Application.BoardsandCommissionsLINQDataContext" EntityTypeName="" TableName="M_BoardsandCommissions" Where="BoardCommissionKey == @BoardCommissionKey" EnableDelete="True" EnableUpdate="True" EnableInsert="True">
        <WhereParameters>
            <asp:QueryStringParameter Name="BoardCommissionKey" QueryStringField="B" Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>


     <asp:FormView ID="BoardDetails" runat="server" DataKeyNames="BoardCommissionKey" DataSourceID="BoardDetails_LDS" Style="float: left; width: 60%" DefaultMode="Edit">
  <EditItemTemplate>
                <ul>
                    <li>
                        <span style="float: left">BoardCommissionKey:</span>
                        <asp:Label ID="BoardCommissionKeyLabel1" Style="float: right" runat="server" Text='<%# Eval("BoardCommissionKey") %>' />
                    </li>
                    <br />
                    <br />
                    <li>
                        <span style="float: left">Board or Commission Name:</span>
                        <asp:TextBox ID="Board_or_Commission_NameTextBox" Style="float: right" runat="server" Text='<%# Bind("Board_or_Commission_Name") %>' />
                    </li>
                    <br />
                    <br />
                    <%--                            <li>
                <span style="float: left">ApplicationXML:</span>
            <asp:TextBox ID="ApplicationXMLTextBox" Style="float: right" runat="server" Text='<%# Bind("ApplicationXML") %>' />
                            </li>
                            <br />
                            <br />--%>
<%--                    <li>
                        <span style="float: left">Description:</span>
                        <asp:TextBox ID="DescriptionTextBox"  Style="float: right" CausesValidation="false" runat="server" 
                            Text='<%# Bind("Description")%>' />
                    </li>
                    <br />
                    <br />--%>
                    <li>
                        <span style="float: left">Default Contact Name:</span>
                        <asp:TextBox ID="Default_Contact_NameTextBox" Style="float: right" runat="server" Text='<%# Bind("Default_Contact_Name") %>' />
                    </li>
                    <br />
                    <br />
                    <li>
                        <span style="float: left">Default Email:</span>
                        <asp:TextBox ID="Default_EmailTextBox" Style="float: right" runat="server" Text='<%# Bind("Default_Email") %>' />
                    </li>
                    <br />
                    <br />
                    <li>
                        <span style="float: left">Default Phone:</span>
                        <asp:TextBox ID="Default_PhoneTextBox" Style="float: right" runat="server" Text='<%# Bind("Default_Phone") %>' />
                    </li>
                    <br />
                    <br />
                    <li>
                        <span style="float: left">Default Web:</span>
                        <asp:TextBox ID="Default_WebTextBox" Style="float: right" runat="server" Text='<%# Bind("Default_Web") %>' />
                    </li>
                    <br />
                    <br />
                    <li>
                        <span style="float: left">Appointment Type:</span>
                        <asp:TextBox ID="Appointment_TypeTextBox" Style="float: right" runat="server" Text='<%# Bind("Appointment_Type") %>' />
                    </li>
                    <br />
                    <br />
                    <li>
                        <span style="float: left">Authority:</span>
                        <asp:TextBox ID="AuthorityTextBox" Style="float: right" runat="server" Text='<%# Bind("Authority") %>' />
                    </li>
                    <br />
                    <br />
                    <li>
                        <span style="float: left">Term Length:</span>
                        <asp:TextBox ID="TermLengthTextBox" Style="float: right" runat="server" Text='<%# Bind("TermLength") %>' />
                        <asp:RequiredFieldValidator ID="TermLengthTextBoxRequiredFieldValidator" ControlToValidate="TermLengthTextBox" Style="float: right; margin-right: 10px; color: Red" runat="server" ErrorMessage="Must Enter Value"></asp:RequiredFieldValidator>

                    </li>
                    <br />
                    <br />
                    <li>
                        <span style="float: left">Special Requirements:</span>
                        <asp:TextBox ID="Special_RequirementsTextBox" Style="float: right" runat="server" Text='<%# Bind("Special_Requirements") %>' />
                    </li>
                    <br />
                    <br />
                    <li>
                        <span style="float: left">Staff Contact:</span>
                        <asp:TextBox ID="Staff_ContactTextBox" Style="float: right" runat="server" Text='<%# Bind("Staff_Contact") %>' />
                    </li>
                    <br />
                    <br />
                    <li>
                        <asp:LinkButton ID="UpdateButton" Style="float: right" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
                        &nbsp;<asp:LinkButton ID="UpdateCancelButton" PostBackUrl="~/InternalSite/MenuTypem.aspx" Style="float: left" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                        &nbsp<asp:LinkButton ID="DeleteButton" PostBackUrl="~/InternalSite/MenuTypem.aspx" Style="float: left; margin-left: 40%; margin-right: 40%; align-self: center" runat="server" CausesValidation="true" CommandName="Delete" Text="Delete" />
                    </li>
                </ul>
            </EditItemTemplate>
        </asp:FormView>

0 个答案:

没有答案