Thursday, March 31, 2016

Remove HTML tags of Text in EP

I had to retrieve a text value stuck in HTML tags. It was the JobAdText field in HRMRecruitingJobAd table. This field has values like "<BODY>Some description</BODY>" and I had to get the value "Some description".

You can use the below code:

Literal jobAd = this.rightGroup.FindControl("html_JobAd") as Literal;
jobAd.Text = HtmlUtilities.CleanupUnsafeHtml((string)currentJobAdRecord.GetFieldValue("HRMRecruitingJobAd!jobAdText"));

You can take the reference from the standard web control "HcmEPOpenJobsListPagePreviewPart" where the same code is used.

Suggestions and feedback welcome :)

No comments:

Post a Comment