By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,833 Members | 2,067 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,833 IT Pros & Developers. It's quick & easy.

Accessing Embedded Javascript

P: n/a
Hello - i have created a simple composite control with drop down list
displaying the US States. I have also a Javascript (County.js) file embedded
inside the control. The Javascript file has an array of County Names. IN
another Javascript i have a function that will display a list of county names
for the selected state. I am using the following to register the javascript
rstype = resource type; rsname = fully qualified resource name including the
namespace
csm.RegisterClientScriptResource(rstype, rsname).

After i browse to the page i am able to download the Javascript file by
pasting the WebResource.axd?......... into the Url but my "OnChange" event
for the Drop downlist does not fire. I am not sure why the Onchange is
failing.

Here is how the onchange is wired on the serverside

SelectCtrl.Attributes.Add("onchange", "'<%=
WebResource(AddressCtrl.ChangeImage();) %>'");

any help is appreciated. thanks
Jul 5 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi,

roger31 wrote:
Hello - i have created a simple composite control with drop down list
displaying the US States. I have also a Javascript (County.js) file embedded
inside the control. The Javascript file has an array of County Names. IN
another Javascript i have a function that will display a list of county names
for the selected state. I am using the following to register the javascript
rstype = resource type; rsname = fully qualified resource name including the
namespace
csm.RegisterClientScriptResource(rstype, rsname).

After i browse to the page i am able to download the Javascript file by
pasting the WebResource.axd?......... into the Url but my "OnChange" event
for the Drop downlist does not fire. I am not sure why the Onchange is
failing.

Here is how the onchange is wired on the serverside

SelectCtrl.Attributes.Add("onchange", "'<%=
WebResource(AddressCtrl.ChangeImage();) %>'");

any help is appreciated. thanks
I might be wrong, but...

The string in the "onchange" attribute is executed in the client's
context. For the client, it's the same if the resource is embedded or
not on the server. By using the WebResource.axd, you send the embedded
resource to the client, so the client has it.

Using the client's context, I think it should work if you write

SelectCtrl.Attributes.Add("onchange", "yourClientSideFunction();");

Accepted, of course, that the function yourClientSideFunction is defined
in the script file.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jul 5 '06 #2

P: n/a
Thanks Laurent. I tried that one too but it did not work. Has this worked for
you?

"Laurent Bugnion" wrote:
Hi,

roger31 wrote:
Hello - i have created a simple composite control with drop down list
displaying the US States. I have also a Javascript (County.js) file embedded
inside the control. The Javascript file has an array of County Names. IN
another Javascript i have a function that will display a list of county names
for the selected state. I am using the following to register the javascript
rstype = resource type; rsname = fully qualified resource name including the
namespace
csm.RegisterClientScriptResource(rstype, rsname).

After i browse to the page i am able to download the Javascript file by
pasting the WebResource.axd?......... into the Url but my "OnChange" event
for the Drop downlist does not fire. I am not sure why the Onchange is
failing.

Here is how the onchange is wired on the serverside

SelectCtrl.Attributes.Add("onchange", "'<%=
WebResource(AddressCtrl.ChangeImage();) %>'");

any help is appreciated. thanks

I might be wrong, but...

The string in the "onchange" attribute is executed in the client's
context. For the client, it's the same if the resource is embedded or
not on the server. By using the WebResource.axd, you send the embedded
resource to the client, so the client has it.

Using the client's context, I think it should work if you write

SelectCtrl.Attributes.Add("onchange", "yourClientSideFunction();");

Accepted, of course, that the function yourClientSideFunction is defined
in the script file.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jul 6 '06 #3

P: n/a
Hi,

roger31 wrote:
Thanks Laurent. I tried that one too but it did not work. Has this worked for
you?
So far I made only preliminary tests with the Webresource.axd, I'll have
to test more and get back to you about that.

Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jul 6 '06 #4

P: n/a
Thanks and much appreciated

"Laurent Bugnion" wrote:
Hi,

roger31 wrote:
Thanks Laurent. I tried that one too but it did not work. Has this worked for
you?

So far I made only preliminary tests with the Webresource.axd, I'll have
to test more and get back to you about that.

Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jul 7 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.