2011-05-25 65 views
6

目前我正在像這樣在網格中顯示完整的消息。如何在asp.net中單擊標籤消息時顯示完整消息?

<asp:TemplateField HeaderText="Message" ItemStyle-CssClass="gridlabeltextleftalign"> 
     <ItemTemplate>       
        <div style="word-wrap: break-word; width: 240px; text-align: left"> 
           <asp:Label ID="lblMessage" runat="server" Font-Size="12px" Text='<%#DataBinder.Eval(Container.DataItem, "Message") %>'></asp:Label> 
          </div> 

         </ItemTemplate> 

        </asp:TemplateField> 

我想顯示單行消息時單擊它,然後顯示整個消息。

請告訴我。

+0

你想包裝標籤文本嗎? – 2011-05-25 07:13:37

回答

1

首先顯示一個固定長度的字符串(不是全部消息 - >例如:mes ...)。

在頁面加載中聲明受保護的字符串,然後在每個頁面加載中綁定它。在這之後直接將保護的字符串分配給一個javascript數組。

看到下面的代碼:

在頁面加載

 protected string protectedString = ""; 

在JavaScript函數,應該在鼠標懸停事件被稱爲:

JavascriptArray = "<%= protectedString %>"; 

將數組作爲DIV的innerHTML的。

希望這會有所幫助...