如何在 ASP.Net 工具提示中显示富文本?

发布于 2024-10-10 13:56:13 字数 1572 浏览 9 评论 0 原文

我使用以下代码显示工具提示

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="ID" DataSourceID="AccessDataSource1">
    <Columns>
        <asp:CommandField ShowEditButton="True" />
        <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
            ReadOnly="True" SortExpression="ID" />
        <asp:BoundField DataField="datefu" HeaderText="date" 
            SortExpression="datefu" />
        <asp:TemplateField HeaderText="title" SortExpression="titlefu">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("titlefu") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>

        <a href="#" title="<asp:Literal ID="Label1" runat="server" Text='<%# Eval("fu") %>'/>"/>



        <asp:Label ID="NamePatientLabel" runat="server" Text='<%# Eval("titlefu") %>' />

            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

,显示以下结果

alt text

但是,当我按如下方式编辑文本时(使其在另一个包含富文本编辑器的网格视图中粗体和红色)

我得到以下内容(作为第二个网格视图中的格式化结果)

alt text

但是,当我在第一个 gridview 中查看以显示工具提示时,我得到以下结果

alt text

我真的需要你的帮助将工具提示显示为富文本

虽然很多人说jquery“非常简单”,但如果您有jquery以外的解决方案,请告诉我。

I use the following code to display a tooltip

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="ID" DataSourceID="AccessDataSource1">
    <Columns>
        <asp:CommandField ShowEditButton="True" />
        <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
            ReadOnly="True" SortExpression="ID" />
        <asp:BoundField DataField="datefu" HeaderText="date" 
            SortExpression="datefu" />
        <asp:TemplateField HeaderText="title" SortExpression="titlefu">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("titlefu") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>

        <a href="#" title="<asp:Literal ID="Label1" runat="server" Text='<%# Eval("fu") %>'/>"/>



        <asp:Label ID="NamePatientLabel" runat="server" Text='<%# Eval("titlefu") %>' />

            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

display the following result

alt text

however when i edit the text as follows (making it bold and red in another gridview containing rich text editor)

i get the following (as a formatting result in the second grid view)

alt text

however when i view in the first gridview to display the tooltip i get the following reult

alt text

i really need your help to display the tooltip as rich text

although many people say that jquery is "very easy", please let me know if you have a solution other than jquery.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜无邪 2024-10-17 13:56:13

不要使用浏览器的本机工具提示,而是实现某种气球提示。有很多方法可以做到这一点,本页显示了 jquery 中的 12 种方法 http://www.dreamcss.com/2009/05/12-jquery-tooltip-for-web-developer.html

一个使用 qTip 是向所有包含文本的 a-href 添加一个名为 tooltip 的属性并执行此 jquery 启动脚本

$(document).ready(function() 
{
   $('#content a[tooltip]').each(function()
   {
      $(this).qtip(
      {
         content: $(this).attr('tooltip')
      });
   });
});

Don't use the browser's native tooltip but implement some kind of balloon tip. There are many ways to do this, this page shows 12 ways in jquery http://www.dreamcss.com/2009/05/12-jquery-tooltip-for-web-developer.html

A simple example with qTip is to add an attribute named tooltip to all your a-hrefs containing your text and executing this jquery startup script

$(document).ready(function() 
{
   $('#content a[tooltip]').each(function()
   {
      $(this).qtip(
      {
         content: $(this).attr('tooltip')
      });
   });
});
若有似无的小暗淡 2024-10-17 13:56:13

您可能需要查看 HoverMenuExtender 中的 < a href="http://www.asp.net/ajax/AjaxControlToolkit/Samples/" rel="nofollow">AjaxControlToolkit。尽管有这个名字,它不仅仅显示菜单 - 您可以使用它来弹出窗口。我只是用它来做一些类似于你想做的事情。
例如

<%@ Register TagPrefix="ajaxtoolkit" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
<asp:ScriptManager runat="server" ID="scriptmanager" />
<div>
    <asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="false" CellPadding="2"
        CellSpacing="2">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:Label ID="Label1" Text='<%# Container.DataItem %>' runat="server" />
                    <ajaxtoolkit:HoverMenuExtender runat="server" TargetControlID="Label1" PopupControlID="PopupPanel"
                        ID="hme" PopupPosition="Right" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:Panel ID="PopupPanel" runat="server" BackColor="White">
        <asp:Label ID="Label2" Text="Some text" runat="server" Font-Bold="true" ForeColor="Red" />
    </asp:Panel>
</div>

You might want to take a look at the HoverMenuExtender in the AjaxControlToolkit. Despite the name it doesn't just display menus - you can use it to do popups. I just used it to do something similar to what you want to do.
e.g.

<%@ Register TagPrefix="ajaxtoolkit" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
<asp:ScriptManager runat="server" ID="scriptmanager" />
<div>
    <asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="false" CellPadding="2"
        CellSpacing="2">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:Label ID="Label1" Text='<%# Container.DataItem %>' runat="server" />
                    <ajaxtoolkit:HoverMenuExtender runat="server" TargetControlID="Label1" PopupControlID="PopupPanel"
                        ID="hme" PopupPosition="Right" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:Panel ID="PopupPanel" runat="server" BackColor="White">
        <asp:Label ID="Label2" Text="Some text" runat="server" Font-Bold="true" ForeColor="Red" />
    </asp:Panel>
</div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文