Monday, March 26, 2012

mixed HTML content in GridView

Hi,
I have some alert data from our monitoring system i want to show in a
gridview's cell.
An alert's data has mixed content... for example:
"
<B>Alert Name:</B> Some Alert Name
<BR><B>Alert Detail:</B> Detail of alert: failed to run this script
<SCRIPT>alert('hi')</SCRIPT>
"
In order for it to parse the <B> & <BR> for each of the field names, I
need to run the cell's text through HTMLDecode, but when I do that, it
also decodes the <SCRIPT> as well and runs it...
I run the HTMLDecode on RowDataBound event, but I also tried to run it
when I prepare the data column and then I have control and can decode
only the field names... but it doesn't work, the cell displays the
tags 'as is', without parsing them.
Anyone has ideas?
Thanks!Place the code to get more insight on what you are exactly doing.
Regards
JIGNESH
"Ben" wrote:

> Hi,
> I have some alert data from our monitoring system i want to show in a
> gridview's cell.
> An alert's data has mixed content... for example:
> "
> <B>Alert Name:</B> Some Alert Name
> <BR><B>Alert Detail:</B> Detail of alert: failed to run this script
> <SCRIPT>alert('hi')</SCRIPT>
> "
> In order for it to parse the <B> & <BR> for each of the field names, I
> need to run the cell's text through HTMLDecode, but when I do that, it
> also decodes the <SCRIPT> as well and runs it...
> I run the HTMLDecode on RowDataBound event, but I also tried to run it
> when I prepare the data column and then I have control and can decode
> only the field names... but it doesn't work, the cell displays the
> tags 'as is', without parsing them.
> Anyone has ideas?
> Thanks!
>
Also to emit any script use following approach.
string script = "";
ClientScriptManager scriptMgr = pagename.ClientScript;
Type csType = this.GetType();
script = "<SCRIPT language='javascript'>" +
"alert('" + sMessage + "');" +
"</SCRIPT>";
scriptMgr.RegisterStartupScript(csType,"MyAlert", script);
Regards
JIGNESH
"JIGNESH" wrote:
> Place the code to get more insight on what you are exactly doing.
> Regards
> JIGNESH
> "Ben" wrote:
>
On Jan 7, 3:12=A0am, JIGNESH <JIGN...@.discussions.microsoft.com> wrote:
> Also to emit any script use following approach.
> string script =3D "";
> =A0 =A0 =A0 =A0 ClientScriptManager scriptMgr =3D pagename.ClientScript;
> =A0 =A0 =A0 =A0 Type csType =3D this.GetType();
> =A0 =A0 =A0 =A0 script =3D "<SCRIPT language=3D'javascript'>" +
> =A0 =A0 =A0 =A0 =A0 =A0 "alert('" + sMessage + "');" +
> =A0 =A0 =A0 =A0 =A0 =A0 "</SCRIPT>";
> =A0 =A0 =A0 =A0 scriptMgr.RegisterStartupScript(csType,"MyAlert", script);=[/color
]
> Regards
> JIGNESH
>
> "JIGNESH" wrote:
>
>
>
>
>
>
>
>
>
>
> - Show quoted text -
I think maybe i didn't explain it properly. I'm not trying to run any
scripts. But I have a table that hold alerts (from our NetIQ
monitoring tool) -- some of the alerts are for websites have an
error... and those alerts include in their data the content of the
page which may include <SCRIPT> tags.
I want to display the alert in a GridView column, but that column
should have some of the HTML parse, and some not... (i don't want to
split to different column, since each alert has different
properties... so I highlight the property name with <B>, which should
be parse, but the data that follows should not be parse since it could
contain some script content that i don't want to run)

0 comments:

Post a Comment