On 10/01/07, Stefan Holmberg <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have been working these last months to try to find out a way of nicely
> getting JQuery and ASP.NET (especially when using master pages) to get along
> when it comes to development.
>
> If there are any more ASP.NET people here then I have the a free (of course)
> control (sourcecode as well) available for download (and docs) at
>
> http://www.aspcode.net/articles/l_en-US/t_default/ASP.NET/ASP.NET2.0/Controls/ASPCodeHeaderManager/category_66.aspx
>
> While it started out as a pure JQuery control I soon saw the use of other
> stuff as well but the JQuery specific stuff is described here
>
> http://www.aspcode.net/articles/l_en-US/t_default/ASP.NET/ASP.NET-2.0/Controls/ASPCodeHeaderManager/The-JQuery-specifics_article_428.aspx
>
> In short the control lets you (even in master page scenarios) control
> javascript file inclusions (with optional runtime whitespace removal,
> obfuscating and packing etc), getting a single document.ready function even
> if multiple independent controls are creating such etc.
>
> I feel so good :) - Now I have a framework good enough for me to really
> start developing some sites instead of just experimenting and creating
> plumbing code. However I guess - maybe now the fun part is over, don't you
> think...It's not the goal but the journey...
>
> I will try marketting it at some asp.net specific sites - maybe I could get
> some more over to the jquery side :)
> --


That looks like it could be handy. ASP.NET does seem to favour inline
JavaScript/CSS etc over properly included (i.e. in <head>) scripts.

This is how I am doing it now:

<head runat="server">
        <title>Untitled Page</title>
        <link href="/css/default.css" rel="stylesheet" type="text/css" />
        <!--[if IE]>
    <link rel="stylesheet" type="text/css" href="assets/css/default_ie.css" />
    <![endif]-->

        <script src="/js/jquery-latest.pack.js" type="text/javascript"></script>

        <script src="/js/global.js" type="text/javascript"></script>

        <asp:contentplaceholder id="extraHeaderContent" runat="server">
        </asp:contentplaceholder>
</head>

Utility class functions:

public static void AddStyleSheet(Page p, string path)
{
        if (p.Header != null)
        {
                HtmlLink styleSheet = new HtmlLink();
                // relative to master page
                styleSheet.Href = path;
                styleSheet.Attributes["type"] = "text/css";
                styleSheet.Attributes["rel"] = "stylesheet";
                p.Header.Controls.Add(styleSheet);
        }
}

public static void AddScript(Page p, string path)
{
        LiteralControl s = new LiteralControl();
        s.Text = String.Format("<script type=\"text/javascript\"
src=\"{0}\"></script>", p.ResolveClientUrl(path));
        p.Header.Controls.Add(s);
}

MasterPages never resolve URL's for script elements, so it has be
changed if added to a virtual application)

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to