Friday, September 12, 2008

Adding page specific scripts (java scripts), styles to web content pages: Microsoft ASP.NET

protected void Page_Load(object sender, EventArgs e)
{
    ///
    /// modify existing meta defined in master page 
    /// 
    HtmlMeta meta = Page.Header.FindControl("metaRedirect"as HtmlMeta;
    foreach (string metadata in MetaDataCollection)
        meta.Content += metadata;
    ///
    /// adding content specific styles into content page's header 
    /// 
    HtmlLink link = new HtmlLink();
    link.Href = "~/styles/default.css";
    link.Attributes["rel"] = "stylesheet";
    Page.Header.Controls.Add(link);
    ///
    /// adding content specific scripts into content page’s header 
    /// 
    HtmlGenericControl script = new HtmlGenericControl("script");
    script.Attributes["src"] = Page.ResolveUrl("~/scripts/default.js");
    Page.Header.Controls.Add(script);
}
public IEnumerable<string> MetaDataCollection { getset; }

No comments:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...