View Full Version : passing html content to a javascript function as a parameter

05-14-2011, 04:14 PM
please help me with this...
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>there</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 as i dont know if the way i am passing the second param ErrorMessage correctly.

Appreciated Much!