Set Path to Root in JavaScript
<p>I'm doing a quick port of an ASP.NET Web Application Project from 1.1 to 2.0. So, instead of a master page the template was created as a custom control. There is a search box in the side panel which is accessible from every page on the site. The panel contains two text boxes for first and second names.</p>

<p>On submitting the search params as query strings, the user is transferred to mysite.com/search/results.aspx. The problem is that depending on where the user submits the search from the path may come up as follows:</p>

<pre><code>mysite.com**/dir1/dir2**/search/results.aspx
</code></pre>

<p>I need to resolve it from the root and it looks like the JS location object is the problem.</p>

<p>Here is the original code. How can I construct the link to resolve from the root?</p>

<pre><code>rightGutter.Controls.Add(new LiteralControl("&lt;script language=javascript&gt;"));
rightGutter.Controls.Add(new LiteralControl
    ("function doPhoneSearch(txtval,txtVal1) {"));
rightGutter.Controls.Add
    (new LiteralControl("location.replace
        ('search/results.aspx?lnamedpco=' + txtval+'&amp;fname='+txtVal1);"));
rightGutter.Controls.Add(new LiteralControl("txtval=\"\";"));
rightGutter.Controls.Add(new LiteralControl("return false;"));
rightGutter.Controls.Add(new LiteralControl("}"));
rightGutter.Controls.Add(new LiteralControl("&lt;/script&gt;"));


HtmlTableCell rightCell8 = new HtmlTableCell();
rightCell8.Attributes.Add("align", "right");
rightCell8.Controls.Add
    (new LiteralControl
        ("&lt;a onClick=\"doPhoneSearch(document.getElementsByName
            ('lnamedpco')[0].value,
                document.getElementsByName('fname')[0].value)\"&gt;"));
Image bgImage5 = new Image();
bgImage5.ImageUrl = "~/images/gobtn.gif";
bgImage5.Attributes.Add("runat", "server");
rightCell8.Controls.Add(bgImage5);
rightCell8.Controls.Add(new LiteralControl("&lt;/a&gt;"));   


&lt;a onClick=\"doPhoneSearch(document.getElementsByName('lnamedpco')[0].value,
    document.getElementsByName('fname')[0].value)\"&gt;
        &lt;img SRC=\"http://mysite/images/gobtn.gif\" 
             BORDER=\"0\" ALT=\"Submit Form\"&gt;
&lt;/a&gt;
</code></pre>
