why java script cannot access this asp.net var?
<p>I have this c# user control class:</p>

<pre><code>public partial class UserControls_JsTop : System.Web.UI.UserControl
{
    public static string sidebarBannerUrl = getSideBarBannerImgUrl();

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public static string getSideBarBannerImgUrl(){
        DataClassesDataContext db = new DataClassesDataContext();
        var imgUrl = (from b in db.Banners
                      where b.Position.Equals(EBannersPosition.siderbar.ToString())
                      select b).FirstOrDefault();
        if (imgUrl != null)
            return imgUrl.Path;
        return String.Empty;

    }
}
</code></pre>

<p>I try to acces the static var in a js script:</p>

<p>load it here:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    var categoryParam = '&lt;%# CQueryStringParameters.CATEGORY %&gt;';
    var subcategory1Param = '&lt;%# CQueryStringParameters.SUBCATEGORY1_ID %&gt;';
    var subcategory2Param = '&lt;%# CQueryStringParameters.SUBCATEGORY2_ID %&gt;';
    var imgUrl = '&lt;%# UserControls_JsTop.sidebarBannerUrl %&gt;';
&lt;/script&gt;
</code></pre>

<p>and use it here (imgUrl):</p>

<pre><code>&lt;script type="text/javascript" language="javascript"&gt;
    $(function () {
        $(document.body).sidebar({
            size: "30px", // can be anything in pixels
            length: "270px", // can be anything in pixels
            margin: "300px", // can be anything in pixels
            position: "left", // left / bottom / right / top
            fadding: "0.8", // 0.1 to 1.0 
            img: imgUrl,
            openURL: "www.twitter.com/amitspatil"
        });
    }); 

 &lt;/script&gt;
</code></pre>

<p>I do not understand why it is empty.
Please trust me that there is a record in DB with that condition.</p>

<p>I think there is some js problem when loading the var...</p>

<p>Do you know where?</p>

<p>thanks</p>
