This is a migrated thread and some comments may be shown as answers.

Call the built-in StripHtmlTags in a user function

3 Answers 175 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andrew Kortuem
Top achievements
Rank 1
Andrew Kortuem asked on 21 Oct 2010, 10:48 PM
I'd like to call the built-in StripHtmlTags function in a user function, like this:

public static string MyFunction ( string pHtmlString )
{
    string plainText = StripHtmlTags ( pHtmlString );
    //do stuff here
    return plainText;
}

Is this possible? What namespace contains this function?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 1
answered on 22 Oct 2010, 03:51 PM
It appears that MyFunction() is simply a wrapper for the built-in StripHtmlTags() function... which is not necessary, unless of course the "// do stuff here" is in fact doing something with plainText before it returns it to the caller. If there *is* some other work being done, put MyFunction() in a utilities class that resides in the same namespace as your reports class. Then, because the StripHtmlTags() method is not exposed for public consumption, or at least I can't find it, pass the returned value of StripHtmlTags() to your user function; i.e.:


/// <summary>
/// Performs additional work on the html string after StripHtmlTags() has done it's thing
/// </summary>
/// <param name="pHtmlString"></param>
/// <returns></returns>
public static string MyFunction(string pHtmlString)
{
  string plainText = pHtmlString;
  
  // do stuff here
    
  return (plainText);
}

In UserFunctions-MyFunction.jpg, I'm referencing the function created above, then in MyFunction-StripHtmlTags.jpg I'm sending the results from StripHtmlTags("<b>Hello World</b>") to the user function. In MyFunction-Results.jpg, you can see the end result.

HTH


0
Andrew Kortuem
Top achievements
Rank 1
answered on 22 Oct 2010, 04:29 PM
Sorry, my example made the function look a little more useless than it is. I'm trying to work with both the HTML version of the string and the tag-stripped version inside the function. I have it set up now so I pass two parameters, but that's a little clunky for the people using the function to write the reports.

Thank you for the thorough reply! I think I may have to stick with what I have. As you say, it doesn't look like that method is publicly exposed.
0
Steve
Telerik team
answered on 22 Oct 2010, 05:00 PM
Hello Andrew,

The purpose of the built-in function is to be used in item expression and not in a user function, which are there to allow you to extend the default behavior of the Reporting engine. In other words, use the following expression directly in a report item. This way you can work with both HTML and tag-stripped version:

tag-stripped
= StripHtmlTags(Fields.MyHtmlColumn)

HTML
= Fields.MyHtmlColumn

Regards,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Andrew Kortuem
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 1
Andrew Kortuem
Top achievements
Rank 1
Steve
Telerik team
Share this question
or