JavaScript in MasterPages [asp.net 2.0]
-
As long as MasterPage and WebForm are in the same directory the JavaScript file works but when the directories are different I get javascript error cuz the file was not found. I tried to google this problem and found that if you put the script block within the < HEAD >, ASP.NET 2.0 runtime will resolve the URL but for some odd reason that is not the case here. Here is how I am doing it: the file is inside a folder called JavaScript which is right under root folder. I tried this first:
Then I tried this:
Then I tried this, but I got an ugly error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
type="text/javascript">
Can someone tell me how to take care of this problem:confused:. Thanks in advance. -- modified at 8:58 Thursday 4th May, 2006
-
As long as MasterPage and WebForm are in the same directory the JavaScript file works but when the directories are different I get javascript error cuz the file was not found. I tried to google this problem and found that if you put the script block within the < HEAD >, ASP.NET 2.0 runtime will resolve the URL but for some odd reason that is not the case here. Here is how I am doing it: the file is inside a folder called JavaScript which is right under root folder. I tried this first:
Then I tried this:
Then I tried this, but I got an ugly error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
type="text/javascript">
Can someone tell me how to take care of this problem:confused:. Thanks in advance. -- modified at 8:58 Thursday 4th May, 2006
Hi, Try below code,
Hope it works...:)
-
As long as MasterPage and WebForm are in the same directory the JavaScript file works but when the directories are different I get javascript error cuz the file was not found. I tried to google this problem and found that if you put the script block within the < HEAD >, ASP.NET 2.0 runtime will resolve the URL but for some odd reason that is not the case here. Here is how I am doing it: the file is inside a folder called JavaScript which is right under root folder. I tried this first:
Then I tried this:
Then I tried this, but I got an ugly error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
type="text/javascript">
Can someone tell me how to take care of this problem:confused:. Thanks in advance. -- modified at 8:58 Thursday 4th May, 2006
Hi, Try below code,
Hope it works..:)
-
Hi, Try below code,
Hope it works...:)
Thanks for the reply, but
does not work.
-
As long as MasterPage and WebForm are in the same directory the JavaScript file works but when the directories are different I get javascript error cuz the file was not found. I tried to google this problem and found that if you put the script block within the < HEAD >, ASP.NET 2.0 runtime will resolve the URL but for some odd reason that is not the case here. Here is how I am doing it: the file is inside a folder called JavaScript which is right under root folder. I tried this first:
Then I tried this:
Then I tried this, but I got an ugly error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
type="text/javascript">
Can someone tell me how to take care of this problem:confused:. Thanks in advance. -- modified at 8:58 Thursday 4th May, 2006