mixed HTML content in GridView

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

JIGNESH

Place the code to get more insight on what you are exactly doing.

Regards
JIGNESH
 
J

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
 
B

Ben

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,110
Latest member
OdetteGabb
Top