获取模式弹出窗口以正确显示填充文本框的问题

时间:2011-08-30 18:54:34

标签: asp.net vb.net listview textbox modalpopupextender

我的网站上有我们销售的产品的说明,我目前正试图让这些说明在模式popupextender中弹出。我可以使用我已启用=“false”的文本框弹出它们,以便无法对其进行编辑,但它会显示所有标记以及<p><li>等文本等。我可以在我的模态中使用不同的控件来更好地显示我的文字吗?

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

以下是&lt;%#Eval(“MarketingData”)%&gt;的示例:       <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 个答案:

答案 0 :(得分:2)

如果文字不可编辑,为什么不使用asp:标签?

MarketingData字段是否包含html标记?请提供MarketingData值的示例。

修改 如果您知道文本中可以存在标签,则可以在类中创建一个属性,该属性包含名为MarketingData的propoerty,如下所示:

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

然后将文本框中的绑定更改为:

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

替换有点难看,希望你可以让它看起来更好;)

答案 1 :(得分:1)

我认为Literal对于此类内容是最合适的控件,因为它会在内容中保留HTML。您也可以使用Label。

如果你更喜欢坚持使用TextBox,我会尝试将ReadOnly属性设置为false(而不是Enabled)。如果你想实现残疾人。