将列表项获取到多行文本框

发布于 2025-01-08 12:50:10 字数 1171 浏览 2 评论 0原文

我有一个关于如何从列表项获取值到多行文本框的问题。 我已经尝试了很多。第一次它给出了正确的数据。 它仍然提供了正确的数据,但是它还随数据一起获取 div 标签。 如果有任何想法请帮忙。

这是我的代码:

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

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>

预期输出是:

Correct Value is here

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

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.

Here is my code:

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

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

The actual out put i am getting is :

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

Where as the expected output is:

Correct Value is here

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疯狂的代价 2025-01-15 12:50:10

尝试 SPHttpUtility.ConvertSimpleHtmlToText

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

Try SPHttpUtility.ConvertSimpleHtmlToText

TxtPrerequisite1.Text = 
    SPHttpUtility.ConvertSimpleHtmlToText(oPrerequisite, oPrerequisite.Length);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文