1) I have built a simple page with jQuery onClick events. I call my Javascript files using the script tag and than source.
like this: <script type="text/javascript" src="assets/scripts/the-needed-javascript-file.js" />
The form is on a page signup.aspx. When I use routing my signup.aspx page to "~/signup.aspx",
my Javascript does not load, only when I access it from the regular signup.aspx page.
Because of that , all my jQuery functions does not work. BTW: the jquery latest build is being called alright, because it is taken from an URL outside m application using "http://jquery.com/....".
I aso tried to remove routing for JS files, but it doesn't solved anything:
routes.Ignore("{*alljs}", new { alljs = @".*\.js(/.*)?" });
2) The secon problem is when I put the full url in the Javascript src, the jQuery click and all the other functions, still didn't load correctly.
Idanchik
0 Points
3 Posts
jQuery and Routing problems
May 08, 2010 03:17 PM|LINK
Hi guys,
I need your help.
Routing and loading JS files
1) I have built a simple page with jQuery onClick events. I call my Javascript files using the script tag and than source.
like this: <script type="text/javascript" src="assets/scripts/the-needed-javascript-file.js" />
The form is on a page signup.aspx. When I use routing my signup.aspx page to "~/signup.aspx", my Javascript does not load, only when I access it from the regular signup.aspx page.
The routing line in my Global.asax.cs:
routes.MapPageRoute("signup","signup/", "~/Signup.aspx");
Because of that , all my jQuery functions does not work. BTW: the jquery latest build is being called alright, because it is taken from an URL outside m application using "http://jquery.com/....".
I aso tried to remove routing for JS files, but it doesn't solved anything:
routes.Ignore("{*alljs}", new { alljs = @".*\.js(/.*)?" });
2) The secon problem is when I put the full url in the Javascript src, the jQuery click and all the other functions, still didn't load correctly.
Best help me out, I am stuck!!
Idan
jquery routing asp.net
raju dasa
Star
14410 Points
2451 Posts
Re: jQuery and Routing problems
May 08, 2010 07:03 PM|LINK
HI,
try using:
.. src=<% Page.ResolveUrl("~/assets/scripts/the-needed-javascript-file.js") %> />
and try accessing the .js file from browser directly.
---------------
Happy Coding.
Mark as Answer if it helps.
rajudasa.blogspot.com || blog@opera