View Full Version : passing an html content to a javascript code function from a c# code

05-16-2011, 08:26 AM
i have a code block in a class file which contains following piece of code
<code block>
HtmlImage mainPic = new HtmlImage();
mainPic.Attributes.Add("onclick", "MainPictureClick('" + GUID + "','" + ErrorMessage + "');");
<code block>
actually it is binding a javascript function MainPictureClick to onlick event with a parameter
i.e; MainPictureClick(idSuffix, noFlashUrl)
"ErrorMessage". this parameter is containing the html content which is passed to the function.
Now when the function executes we are using
errorContainer - a div and using innerHTML binding the html content received as a parameter to it.
errorContainer.innerHTML = noFlashUrl;

but when the html content contains two "h1" it gives error
say <h1>hi</h1> <h1>h2</h2> it does not work..could you please help me in this.
There must be some workaround to pass to a javascript function parameter as html.
Appreciated Much!