tag:blogger.com,1999:blog-8980734269859237005.post7594765222300982414..comments2024-01-30T01:03:21.768-08:00Comments on DevCurry: How to add CSS Programmatically to an ASP.NET PageSuprotim Agarwalhttp://www.blogger.com/profile/08349831623922214390noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-8980734269859237005.post-44975824100611012772015-01-22T21:34:44.831-08:002015-01-22T21:34:44.831-08:00Why not define a generic HTML <link> and set...Why not define a generic HTML <link> and set the HREF programmatically? <br /><br />For example, in the source page <head>, add, "<link id="cssStyle" runat="server" rel="stylesheet" type="text/css" />". Then, in Page_Load set the Href property of cssStyle:<br />cssStyle.Href = "path/to/Styles.css";<br /><br />Seems a Anonymoushttps://www.blogger.com/profile/09070989112846292946noreply@blogger.comtag:blogger.com,1999:blog-8980734269859237005.post-24905841664055759812012-07-31T04:14:20.092-07:002012-07-31T04:14:20.092-07:00Nice! Thanks for sharing your solution hereNice! Thanks for sharing your solution hereSuprotim Agarwalhttps://www.blogger.com/profile/08349831623922214390noreply@blogger.comtag:blogger.com,1999:blog-8980734269859237005.post-14901997501881975052012-07-31T02:09:37.087-07:002012-07-31T02:09:37.087-07:00I went a step over, I wanted a method that makes m...I went a step over, I wanted a method that makes me impossible to include duplicates, something like ClientScriptManager.RegisterClientScriptInclude().<br />The solution is to give an ID to the control added in the Header section.<br /><br /> if (!String.IsNullOrEmpty(Key))<br /> if (Page.Header.FindControl(Key) != null) return;<br /> <br /> HtmlLink link = new HtmlLink();<br /> Igorhttp://www.idea-r.itnoreply@blogger.comtag:blogger.com,1999:blog-8980734269859237005.post-59534962250934354662009-09-19T08:46:51.498-07:002009-09-19T08:46:51.498-07:00Perfect! Thanks for this nice tip!Perfect! Thanks for this nice tip!urbannoreply@blogger.com