Re: It's trying to compile my JavaScript?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi again,

I'm running from the ASP.NET web server, so the root of the application
isn't the root of the server, e.g.:
http://localhost:4629/MyApplication/Home.aspx

So I can't just a straight / without rebasing it with the ~ (or another
method)

Thanks again for trying!

"Islamegy®" wrote:

i don't know why u don't add it dynamicly like you do in meta tags, so u
don't have to change it the masterpage or forms, u can store it fixed in
web.config and add it from code behind.. easy huh?

you masy also right it like this
<script type="text/javascript" src="/scripts/master.js">
when use just "/" it's mean relative path from the root..

That's all i have..




"Boris Yeltsin" <borisy@xxxxxxxxxxxxx> wrote in message
news:3223AE33-CF95-40BB-9E24-8621858CA84A@xxxxxxxxxxxxxxxx
Hi Islamegy,

1) I'm not sure this will work for me. Doesn't the <base> tag need an
absolute URL? Even if it takes a relative URL, I'll still have to do
something to update the 'href' attribute on the fly to make it point to
the
right level, such as:
<base href="~/" runat="server" />
(which doesn't work - I tried it - but ASP.NET doesn't parse the ~)

2) I'm using code-behind solutions for adding dynamic meta-tags, but
that's
because they're dynamic. My JavaScript file is fixed, so I'd much prefer
the
reference in the markup and not in the code-behind :)

Thanks...

"Islamegy®" wrote:

Why you try to make it harder...
There is more simple solutions
1- add html <Base> tag after head..
2- make <head runat="server"> then u can access it from code and add
anything you want here is example

foreach (Control ctrl in this.Master.Controls)
{
if (ctrl is HtmlHead)
{
HtmlTitle title = new HtmlTitle();
title.Text = Convert.ToString(hdt.Rows[0]["Title"]);

Literal baseurl = new Literal();
baseurl.Text = string.Format("<base href=\"{0}\">",
ConfigurationManager.AppSettings.Get("BaseURL"));


HtmlMeta desc = new HtmlMeta();
desc.Name = "Description";
desc.Content =
Convert.ToString(hdt.Rows[0]["Description"]);

HtmlMeta keyword = new HtmlMeta();
keyword.Name = "Keyword";
keyword.Content =
Convert.ToString(hdt.Rows[0]["Keyword"]);

Literal additional = new Literal();
additional.Text =
Convert.ToString(hdt.Rows[0]["AdditinalHeadTags"]);

HtmlHead head = (HtmlHead)ctrl;
head.Controls.AddAt(0, title);
head.Controls.AddAt(1, baseurl);
head.Controls.AddAt(2, desc);
head.Controls.AddAt(3, keyword);
head.Controls.AddAt(4, additional);
}



"Boris Yeltsin" <borisy@xxxxxxxxxxxxx> wrote in message
news:B04EE22B-F242-42E8-B6A0-0455825DCAC0@xxxxxxxxxxxxxxxx
I use Master Pages, so I make use of URL rebasing through the ~
operator,
like this in the <head>:
<link runat="server" href="~/Root.master.css" media="screen"
rel="stylesheet" type="text/css" />

It works perfectly and the ~ gets converted by the server into the
correct
relative path. Great!

Now, I put this in the <head>:
<script type="text/javascript" src="~/Root.master.js"
runat="server"></script>

And everything screws up. It looks like it's trying to compile that .js
file
into the page as the CLR throws up syntax errors and compiler errors in
my
JavaScript (which is valid JavaScript).

What am I doing wrong? :(






.



Relevant Pages

  • Re: Determine if a File exists
    ... or simply a relative path from the root will always work too ... File.IO needs the fully qualified path. ... the web server, that command will not work because I can not specify the ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Detecting if connected to the internet
    ... issue a DNS request to a root name server. ... it can't be done with JavaScript ... But the runtime environment must provide a ...
    (comp.lang.javascript)
  • Re: Detecting if connected to the internet
    ... issue a DNS request to a root name server. ... it can't be done with JavaScript ... But the runtime environment must provide a ... IF I want a name resolved I ask MY name server, and chances are it WILL contact the root servers if its in an unusual domain. ...
    (comp.lang.javascript)
  • RFX Networks/ RackAdmin.com ALERT
    ... below was posted to some security websites. ... | in security and scalable server management on varying levels. ... Got Root? ... Your Server login ID is: ...
    (comp.os.linux)
  • RFX NETWORKS ALERT
    ... below was posted to some security websites. ... | in security and scalable server management on varying levels. ... Got Root? ... Your Server login ID is: ...
    (alt.linux)