2011-08-30 90 views
0

我的網站對我們銷售的產品有描述,我目前正試圖讓這些描述在模態popupextender中彈出。我可以讓他們彈出一個文本框,我已啓用=「false」,以便它不能被編輯,但它會顯示所有標籤以及文本,例如<p><li>等。是否有其他控件我可以在我的模式裏面使用,這會更好地顯示我的文字?使ModalPopUp正確顯示填充文本框的問題

<!-- Descriptions --> 
<asp:TabPanel ID="tab2" runat="server" HeaderText="Descriptions"> 
<HeaderTemplate>Descriptions</HeaderTemplate> 
    <ContentTemplate> 
     <ul class="info"> 
     <asp:ListView ID="lvDescriptions" runat="server" DataSourceID="dsMarketingDescriptions" DataKeyNames="MarketingID"> 
     <ItemTemplate> 
      <li> 
       <asp:LinkButton ID="ViewDescriptionButton" runat="server"><%#Eval("MarketingTitle")%></asp:LinkButton> 
       <asp:ImageButton ID="DeleteDescriptionButton" runat="server" Style="float:right;" AlternateText="" ImageUrl="../../images/delete.png" CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete this description?')" /> 
       <asp:Panel ID="ViewDescriptionPanel" runat="server"> 
        <asp:ImageButton ID="CancelDescriptionButton" runat="server" ImageUrl="../../images/exit.png" AlternateText="" Style="float:right;"/> 
        <asp:TextBox ID="Description" runat="server" width="100px" height="100px" Enabled="false" TextMode="MultiLine" Text='<%# Eval("MarketingData") %>'/> 
       </asp:Panel> 
       <asp:ModalPopupExtender ID="ViewDescriptionModal" runat="server" BackgroundCssClass="modalBackground" DropShadow="false" DynamicServicePath="" Enabled="true" PopupControlID="ViewDescriptionPanel" TargetControlID="ViewDescriptionButton" CancelControlID="CancelDescriptionButton"></asp:ModalPopupExtender>    
      </li> 
     </ItemTemplate> 
     </asp:ListView> 
     </ul> 
    </ContentTemplate> 
</asp:TabPanel> 

這裏的<%#的eval( 「MarketingData」)%>的例子: <p>If you are currently trading options on futures or are interested in exploring them further, check out this newly updated trading guide, featuring 25 commonly used options strategies, including butterflies, straddles, strangles, backspreads and conversions. Each strategy includes an illustration demonstrating the effect of time decay on the total option premium involved in the position.</p><p>Options on futures rank among the most versatile risk management tools, and are offered on most CME Group products. Whether you trade options for purposes of hedging or speculating, you can limit your risk to the amount you paid up-front for the option while maintaining your exposure to beneficial price movements.</p>

回答

2

如果文本不會成爲可編輯的,你爲什麼不使用ASP:標籤呢?

MarketingData字段是否包含html標記?請提供MarketingData價值的示例。

編輯: 如果你知道至極標籤可以出現在你的文字,你可以簡單地創建持有稱爲MarketingData的propoerty,這樣的類的屬性:

public string EditedMarketingData 
{ 
    get {return MarketingData.Replace("<p>","").Replace("</p>","").Replace("<li>","");} 
} 

,然後改變在文本框中的結合:

Text='<%# Eval("EditedMarketingData") %>' 

的更換是一種醜陋的,希望你可以得到更好看;)

+0

是的,他們包括HTML標籤。我不知道爲什麼,但這是他們被放入數據庫的方式,這可能使我們的其他網站更容易。檢查上面的修改。 – jlg

+0

您擁有的其他選項是編輯綁定事件上的文本,但我更願意使用特定的目的屬性,因爲您可能需要在應用程序的其他位置使用它。 – daniloquio

+0

我繼續,並採取了第一個建議,你必須提供,這是使用一個標籤。我在CSS中添加了一些東西,它的工作方式與我以前想要的一樣。標籤比試圖讓文本框不可編輯更容易。感謝您的建議! – jlg

1

我認爲文字是這種類型的內容最合適的控制,因爲它會保留內容中的HTML。你也可以使用標籤。

如果你希望堅持一個文本框,但我會嘗試設置ReadOnly屬性爲false(而不是啓用)。如果你想實現殘疾人。

+0

我不知道我爲什麼使用文本框,當時我想不出任何更好的東西。再次感謝cyberstalk @詹姆斯! :) – jlg

+0

哦,我早些時候嘗試使用文字,但我不熟悉它,所以我用了一個標籤:) – jlg

+0

如果它顯示正確,那就重要了。唯一的區別是標籤將內容包裝在SPAN中。 –