将列表项获取到多行文本框
我有一个关于如何从列表项获取值到多行文本框的问题。 我已经尝试了很多。第一次它给出了正确的数据。 它仍然提供了正确的数据,但是它还随数据一起获取 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试 SPHttpUtility.ConvertSimpleHtmlToText
Try SPHttpUtility.ConvertSimpleHtmlToText