将列表项获取到MultiLine文本框

将列表项获取到MultiLine文本框

本文介绍了将列表项获取到MultiLine文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于如何从列表项中获取值到MultiLine文本框的问题.我已经尝试了很多.第一次给出了正确的数据.仍然可以提供正确的数据,但是它也会与数据一起获取div标签.有什么想法请帮忙.

I have a question regarding how to fetch a value from list item to a MultiLine textBox.I have tried alot. First time it gave the correct data.and still it gives the correct data however it also fetches the div tags along with the data.Any thoughts if any please help.

这是我的代码:

Register.aspx

Register.aspx

<tr>
    <td>
        <asp:Label ID="Label3" runat="server" Text="Prerequisite"></asp:Label>
    </td>
    <td>
        <asp:TextBox ID="TxtPrerequisite1" runat="server" TextMode="MultiLine" ReadOnly="true"></asp:TextBox>
    </td>
</tr>

Register.aspx.cs

Register.aspx.cs

string oPrerequisite = null;
SPSite oSPSiteCollection = SPContext.Current.Site;
SPWeb oSPWeb = SPContext.Current.Web;
SPList oSPList1 = oSPWeb.Lists["Scheduled Courses"];
SPListItemCollection oItemCollectionCourse = oSPList1.Items;
foreach (SPListItem ospListItemCourse in oItemCollectionCourse)
{
    oPrerequisite = ospListItemCourse["Prerequisite"].ToString();
    TxtPrerequisite1.Text = oPrerequisite;
}

我得到的实际输出是:

<div class="ExternalClassEAA502F55D7B4F9BBA347E2137621D8A"><p> Correct Value is here >div </p></div>

预期输出为:

正确的值在这里

如何从正确答案中删除标签,所以我只有值.

How can I remove the tag from the correct answer so I have only value.

推荐答案

尝试 SPHttpUtility.ConvertSimpleHtmlToText

TxtPrerequisite1.Text =
    SPHttpUtility.ConvertSimpleHtmlToText(oPrerequisite, oPrerequisite.Length);

这篇关于将列表项获取到MultiLine文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 09:45