【问题标题】:<a href> tag in TextBox in GridViewGridView 中 TextBox 中的 <a href> 标记
【发布时间】:2018-04-20 05:20:09
【问题描述】:

无论如何,这都不是一个漂亮的应用程序。它仅供少数人在办公室使用,不需要街头吸引力。话虽如此...

我有一个带有以下模板列的网格视图:

    <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>

对于给我造成麻烦的示例,绑定到该列的字段中的数据是:**Testing with a link. &lt;a href="http://www.google.com"&gt;Google&lt;/a&gt;**

ItemTemplate 中的标签按我的预期显示。常规文本没有超链接,超链接文本有。请查看随附的图片: ItemTemplate

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

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

非常感谢任何帮助。

【问题讨论】:

  • 保存/取消按钮:更新 ​​ton> Cancel ​​ton>

标签: html asp.net gridview hyperlink


【解决方案1】:

我认为您在 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

【讨论】:

  • 非常感谢您的意见。我发现您的第一个链接中的解决方案效果很好。我在页面指令中添加了 validateRequest="false"。基于一些额外的研究以及这是一个非常小的仅限 Intranet 的应用程序这一事实,此更改不会对其他任何内容产生不利影响。再次感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-05-12
  • 1970-01-01
  • 2014-12-24
  • 1970-01-01
  • 1970-01-01
  • 2010-11-18
  • 1970-01-01
相关资源
最近更新 更多