2011-01-05 50 views
2

我使用以下代碼如何在工具提示ASP.Net中顯示富文本?

alt text

然而,顯示工具提示

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

顯示以下結果時,我如下編輯該文本(使它紅色粗體顯示在含有富另一個gridview的文本編輯器)

我收到以下內容(作爲第二個網格視圖中的格式化結果)

alt text

然而,當我看到在第一GridView控件顯示工具提示我得到以下reult

alt text

我真的需要你的幫助,以顯示工具提示的富文本

雖然很多人都說jquery「非常容易」,請讓我知道如果你有一個解決方案,而不是jQuery。

+2

也許你應該告訴我們更多關於你很難與詳細的jQuery,因爲我不知道一個工具,它更容易使用的。 – Jan 2011-01-05 14:17:47

回答

2

不要使用瀏覽器的原生工具提示,而是實施某種氣球提示。有很多方法可以做到這一點,該網頁顯示的jQuery 12種http://www.dreamcss.com/2009/05/12-jquery-tooltip-for-web-developer.html

qTip一個簡單的例子是一個名爲工具提示添加屬性包含文本和執行這個jQuery啓動腳本

所有的A-的HREFs
$(document).ready(function() 
{ 
    $('#content a[tooltip]').each(function() 
    { 
     $(this).qtip(
     { 
     content: $(this).attr('tooltip') 
     }); 
    }); 
}); 
+1

雖然很多人都說jquery很「容易」,但我真的很難用它,而且我嘗試了10次以上,總是沒有使用它。我知道這是我的壞,但如果你知道其他方式不jQuery的PLZ告訴我。 – 2011-01-05 14:06:33

2

您可能需要查看AjaxControlToolkit中的HoverMenuExtender。儘管它的名字不僅僅是顯示菜單 - 你可以用它來做彈出窗口。我只是用它來做類似於你想做的事情。
例如

<%@ 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> 
相關問題