Hi,
Does anyone know how to display a field containing text in RTF format as plain text in a radgrid column?
I'm currently using a GridTemplateColumn with a label in its ItemTemplate to display the text.
I've tried a simple GridBoundColumn, but without success.
Thanks for any suggestions.
Jim
Does anyone know how to display a field containing text in RTF format as plain text in a radgrid column?
I'm currently using a GridTemplateColumn with a label in its ItemTemplate to display the text.
I've tried a simple GridBoundColumn, but without success.
Thanks for any suggestions.
Jim
4 Answers, 1 is accepted
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Sep 2011, 10:42 AM
Hello,
You remove html tag with help of below code and let me know if its not working.
oe try with below code.
<telerik:GridBoundColumn HtmlEncode="false"
Thanks,
Jayesh Goyani
You remove html tag with help of below code and let me know if its not working.
using
System.Text.RegularExpressions;
public
static
string
RemoveHTML(
string
in_HTML)
{
string
clearText = Regex.Replace(lv_HTML,
"<(.|\n)*?>"
,
""
);
clearText = System.Web.HttpUtility.HtmlDecode(clearText)
return
clearText;
}
oe try with below code.
<telerik:GridBoundColumn HtmlEncode="false"
Thanks,
Jayesh Goyani
0
jlj30
Top achievements
Rank 2
answered on 11 Sep 2011, 08:08 PM
Hi,
Thanks for the 2 suggestions, but I couldn't get either one to work for me.
What I was able to do was leverage the RadEditor which has a property simply called Text which does exactly what I want.
The label "lblBriefAnswer" is contained within an ItemTemplate of a GridTemplateColumn.
Jim
Thanks for the 2 suggestions, but I couldn't get either one to work for me.
What I was able to do was leverage the RadEditor which has a property simply called Text which does exactly what I want.
The label "lblBriefAnswer" is contained within an ItemTemplate of a GridTemplateColumn.
protected void lblBriefAnswer_PreRender(object sender, EventArgs e)
{
Label lblBriefAnswer = (Label)sender;
lblBriefAnswer.Text = HTML2PlainText(lblBriefAnswer.Text);
}
public static string HTML2PlainText(string htmlText)
{
RadEditor editor = new RadEditor();
editor.Content = htmlText;
String plainText = editor.Text;
return plainText;
}
Jim
0
jlj30
Top achievements
Rank 2
answered on 12 Sep 2011, 06:25 PM
My apologies to Jayesh. The code provided worked just fine.
It must have been a finger check on my part.
Thanks for the solution.
Jim
It must have been a finger check on my part.
Thanks for the solution.
Jim
0
Jayesh Goyani
Top achievements
Rank 2
answered on 12 Sep 2011, 06:33 PM
Hello Jim,
its ok. my friend.
Thanks,
Jayesh Goyani
its ok. my friend.
Thanks,
Jayesh Goyani