views:

61

answers:

3

Hi I have a hyperlink in asp.net that I want to dynamically create. I also add additional attributes like onmouseover to call a javascript function. My problem is that instead of setting my attribute to

onmouseover="myJSFunc('param')" 

it converts it to

onmouseover="myJSFunc('param')". 

Any ideas how to get this to work in ASP.NET C#? Thanks!

Ryan

EDIT:

These controls are in a repeater. This is what I have in my code behind;

hypNav.Attributes.Add("onmouseover", "myJSFunc('" + divNav.ClientID + "')");
A: 

Tried using \' instead of ' ?

Raze2dust
Thanks. Tried that and it's doing the same thing. :(
RyanAdriano
A: 

Use MyControl.Attributes.Add() in your code behind.

Joel Coehoorn
Hi! That's what I'm doing. The problem is that when you look at the HTML source, instead of having ('), i see . And that's why my javascript call don't work.
RyanAdriano
+1  A: 

Seems to be .Net 4.0 issue. Check it out.

x2
That fixed my problem. Thanks!
RyanAdriano