<a href=""> tag in TextBox in GridView

时间:2017-11-07 17:37:45

标签: html asp.net gridview hyperlink

This is not a pretty application by any stretch. It's only meant for a select few to use in the office and does not require street appeal. With that said...

I have a gridview with the following template column:

    <asp:TemplateField HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="lblAction" runat="server" Text='<%#(Eval("Action"))%>' 
                ToolTip="Action to be Taken"></asp:Label>
       </ItemTemplate>
       <EditItemTemplate>
        <asp:TextBox ID="txtAction" runat="server" 
                TextMode="MultiLine" Width="450px" Height="100px" ValidationGroup="UpdateFU"
                     Text='<%#Eval("Action")%>'
                     CssClass="RequiredText" ToolTip="Follow-Up Action">
              </asp:TextBox>
              <asp:RequiredFieldValidator ID="rfv_txtAction" runat="server" 
                ControlToValidate="txtAction" ErrorMessage="FollowUp Action is Required" 
                     Text="*" ValidationGroup="UpdateFU">
              </asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
    <asp:TextBox ID="txtAction" runat="server" 
TextMode="MultiLine" Width="250px" 
ValidationGroup="UpdateFU"
CssClass="RequiredText"
ToolTip="Follow-Up Action">
</asp:TextBox>
<asp:RequiredFieldValidator ID="rfv_txtAction" runat="server" 
ControlToValidate="txtAction" ErrorMessage="FollowUp Action is Required" 
Text="*" ValidationGroup="AddFU">
</asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>

For the example that is causing me trouble, the data in the field that is bound to this column is: **Testing with a link. <a href="http://www.google.com">Google</a>**

The label in the ItemTemplate displays as I expect it to. The regular text is not hyperlinked and the hyperlink text is. Please see the included image: ItemTemplate

当我的行处于编辑模式时,它也会显示在TextBox中,正如我所怀疑的那样。请参阅随附的图片:EditItemTemplate

当我尝试保存或取消记录时,gridview无法识别单击了命令按钮。它只是坐在那里。如果我删除引用该标记的文本(从我的示例**Testing with a link.**中删除),它可以很好地工作。唯一的问题是我无法使用我的链接保存文本框中的任何文本。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

我认为你在GridView周围使用UpdatePanel。这就是为什么在没有检查浏览器控制台的情况下缺少例外的原因。而且这个例外很可能是A potentially dangerous Request.Form value was detected from the client

修复此处

A potentially dangerous Request.Form value was detected from the client

A potentially dangerous Request.Form value was detected from the client

https://www.codeproject.com/Tips/297679/A-potentially-dangerous-Request-Form-value-was-det

https://www.aspsnippets.com/Articles/ASPNet-Error-A-potentially-dangerous-RequestForm-value-was-detected-from-the-client.aspx