"cfps.Christian" <ge*******@otc.eduwrote in message
news:95**********************************@s19g2000 prg.googlegroups.com...
I've written a .js file and put the script in my usercontrol:
<script src="myscript.js" />
Added the attributes to my controls:
lbl.Attributes.Add("onclick", "DoWork(this);")
- Also tried "javascript:DoWork(this);"
- and "javascript:DoWork();" - to see if it was the "this"
I've also tried the RegisterClientScriptInclue() method to register
this script as well to no avail.
Where am I going wrong with this?
Firstly, I'm assuming lbl is an <asp:Labelwebcontrol... If so, it will
render as an HTML <span>. Does it actually contain any text...?
Secondly, do this as a test:
<asp:Label ID="MyTestLabel" runat="server" Text="Click me" />
MyTestLabel.Attributes.Add("onclick", "alert('Hello');");
When you click the word "Hello", do you see the JavaScript alert...?
If you do, then change the onclick attribute to "DoWork(this);" and put the
alert at the top of the DoWork method. Do you see the alert now...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net