I'm unable to refer the images from css file of custom control. I've changed the Build Action of the Image propery as Embedded Resource, Registered above the namespace of custom control. css file is linked in the custom control as below, all the properties
in css file is working except the Image Url.
I'm able to link css file as an embeded resource in project. But not able to use the images reffered in css file.
Since you can embed your resource into project,I think you can directly use that resource in your project instead of using it in CSS file……because CSS file can only contain defined types in the form of string,but your resource isn't always type of that。
anandhan
Member
1 Points
44 Posts
Image Url property in css file is not working (asp.net custom server control)
Apr 05, 2012 03:06 PM|LINK
Hi,
I'm unable to refer the images from css file of custom control. I've changed the Build Action of the Image propery as Embedded Resource, Registered above the namespace of custom control. css file is linked in the custom control as below, all the properties in css file is working except the Image Url.
[assembly: WebResource("CustomServerControl.CSS.DefaultStyleSheet.css", "text/css")] [assembly: WebResource("CustomServerControl.Images.brandbg.png", "image/png")] namespace CustomServerControl { public class ServerControl1 : CompositeControl { protected override void OnInit(EventArgs e) { base.OnInit(e); //Registering StyleSheet file string includeTemplate = "<link rel='stylesheet' text='text/css' href='{0}' />"; string includeLocation = Page.ClientScript.GetWebResourceUrl(this.GetType(), "CustomServerControl.CSS.DefaultStyleSheet.css"); LiteralControl include = new LiteralControl(String.Format(includeTemplate, includeLocation)); ((System.Web.UI.HtmlControls.HtmlHead)Page.Header).Controls.Add(include); //Registering javascript file Page.ClientScript.RegisterClientScriptResource(this.GetType(), "DropdownServerControl.JS.JScript1.js"); } } } //CSS #brandbutton ul .topbrd { background: transparent url('<%=WebResource("CustomServerControl.Images.brandbg.png")%>') no-repeat scroll left top; }The above Image URL property is not working. How to link the image url in css file?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Image Url property in css file is not working (asp.net custom server control)
Apr 07, 2012 01:53 AM|LINK
What do you mean "Link the image url in css file"?What do you want to do?Want to link the css file as an embedded source into the proj or……?
Reguards!
anandhan
Member
1 Points
44 Posts
Re: Image Url property in css file is not working (asp.net custom server control)
Apr 07, 2012 07:42 PM|LINK
Hi,
I'm able to link css file as an embeded resource in project. But not able to use the images reffered in css file.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Image Url property in css file is not working (asp.net custom server control)
Apr 08, 2012 03:27 AM|LINK
Since you can embed your resource into project,I think you can directly use that resource in your project instead of using it in CSS file……because CSS file can only contain defined types in the form of string,but your resource isn't always type of that。