> I've written a .js file and put the script in my usercontrol:
> <script src="myscript.js" />
[quoted text clipped - 8 lines]
>
> Where am I going wrong with this?
Firstly, I'm assuming lbl is an <asp:Label> webcontrol... 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...?

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
cfps.Christian - 11 Dec 2007 16:49 GMT
> > I've written a .js file and put the script in my usercontrol:
> > <script src="myscript.js" />
[quoted text clipped - 26 lines]
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net
I've narrowed it down to it not finding the method. The alert in the
click event works, at the top of the method does not.
Also this is dynamic because I need to create a possibly endless list
and add all the properties to it as I add them. I click each line and
it give me a new line for the javascript error (same error though).
you have one of three errors:
1) DoWork spelled wrong, javascript is case senstive
2) myscript.js has a script tag inside
3) myscript.js is not in the same folder as the page loading the control
turn on javascript debugging in the browser and vs.
-- bruce (sqlwork.com)
> I've written a .js file and put the script in my usercontrol:
> <script src="myscript.js" />
[quoted text clipped - 8 lines]
>
> Where am I going wrong with this?
cfps.Christian - 11 Dec 2007 17:21 GMT
Syntax wise everything is correct, I copy the method names to ensure
that. Also I can get other files to work fine but this is the first
time with the UserControl/Dynamic script thing which is where I'm
getting problems.
The js file is in a different location since this is a user control in
a separate folder.
I tried changing the path to the file to: "~/Controls/myscript.js"
with the same issue
bruce barker - 11 Dec 2007 17:31 GMT
the js file path must be relative to the page folder, not the control.
"~" is not valid in a script tag, only in the url of a server side control,
because thats the only way it gets translated (its not supported by iis or
the browser).
-- bruce (sqlwork.com)
> Syntax wise everything is correct, I copy the method names to ensure
> that. Also I can get other files to work fine but this is the first
[quoted text clipped - 6 lines]
> I tried changing the path to the file to: "~/Controls/myscript.js"
> with the same issue
cfps.Christian - 11 Dec 2007 17:36 GMT
Well you were correct about the having to be in the directory of the
page. I ended up putting the script tag in the calling page rather
than the user control.
Is there no way to reference a js file in a user control and just put
the user control in a page?
bruce barker - 11 Dec 2007 18:28 GMT
make the js file a web resource instead of a file.
-- bruce (sqlwork.com)
> Well you were correct about the having to be in the directory of the
> page. I ended up putting the script tag in the calling page rather
> than the user control.
>
> Is there no way to reference a js file in a user control and just put
> the user control in a page?