mixed HTML content in GridView

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

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
 
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





- 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)
 
Back
Top