locked
Initialize background image url in css file into custom server controls RRS feed

  • Question

  • User1024063827 posted

    hi, 

    i registered an image in AssemblyInfo.cs like this:


    [assembly: WebResource("MyControl.Icons.bold.png", "image/png")]


    .cs

    protected override void RenderContents(HtmlTextWriter output)
            {
                output.Write("<p class='BoldButtons' onclick='event4()'>event4 </p>");
                
                
            }




    now i want to initialize that image in css file for background-image but it dose'nt work.

    my css file is:


    .BoldButtons
    {
    	background-image: url("MyControl.Icons/font_bold.png");
        background-repeat:no-repeat;
    	border: 0px; 
    	height: 21px; 
    	width: 21px;
    }

    i also try with this :


    background-image: url(<%=WebResource("MyControl.Icons.bold.png")%>);

    but it dose'nt work.

    please help me? 




    Wednesday, September 29, 2010 7:09 AM

Answers

  • User1024063827 posted

    oh,

    i found my problem. 

    i should had been added PerformSubstitution = true  for register  css.

    [assembly: WebResource("ServerControl2.Style.css", "text/css", PerformSubstitution = true)]

    and then write css class like this :


    .backGround
    {
    	background-image:url('<%=WebResource("ServerControl2.RichTextboxIcons.bold.png")%>');
    	width:100px;
    	background-repeat:no-repeat;
    }




    is solving my problem

    Thank you



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 30, 2010 5:22 AM

All replies

  • User902066765 posted

    Hi,

    Please use "background-imageurl("MyControl.Icons.bold.png");  "


    Thanks,

    Alpesh


    Wednesday, September 29, 2010 7:15 AM
  • User1024063827 posted

    it dose'nt work Frown 

    Wednesday, September 29, 2010 7:25 AM
  • User1024063827 posted

    oh,

    i found my problem. 

    i should had been added PerformSubstitution = true  for register  css.

    [assembly: WebResource("ServerControl2.Style.css", "text/css", PerformSubstitution = true)]

    and then write css class like this :


    .backGround
    {
    	background-image:url('<%=WebResource("ServerControl2.RichTextboxIcons.bold.png")%>');
    	width:100px;
    	background-repeat:no-repeat;
    }




    is solving my problem

    Thank you



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 30, 2010 5:22 AM