SkinID not working for images

Discussion in 'ASP .Net' started by WT, Feb 5, 2007.

  1. WT

    WT Guest

    Hello,

    In my code I set the SkindId for image objects before the Page_Load event
    for the page.
    The image is created then added to the control list of an HtmlAnchor object
    already present in the ascx page.
    I checked with traces that the skinid is correctlyset, theApp_Theme folder
    contains the correct Theme whichcontains the Skin, and this last file
    contain correct path to the gif image placed in a folder under the
    currenttheme.
    But no image displayed, looking to the generated source I find <img src=""
    ......> ?
    Is thisa known problem ?
    Any help welcome.

    CS
     
    WT, Feb 5, 2007
    #1
    1. Advertising

  2. Howdy,

    I think you haven't set Theme attribute of the page. I copied working
    example for you:
    -- begin aspx code --
    <%@ Page Language="C#" EnableViewState="true" AutoEventWireup="true"
    CodeFile="HelloWorld.aspx.cs" Inherits="HelloWorld"
    Theme="Red" %>

    <html>
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form id="Form1" runat="server">

    <script runat="server">
    protected void Page_Init(object source, EventArgs e)
    {
    Image image = new Image();

    image.ID = "img1";
    image.SkinID = "red";

    myAnchor.Controls.Add(image);

    }
    </script>

    <a href="#" runat="server" id="myAnchor"></a>

    </form>
    </body>
    </html>
    -- end aspx code --

    -- begin skin file --

    <asp:Image runat="server" ImageUrl="~/1.jpg" SkinID="red"/>

    -- end skin file --

    Skin file is put under App_Themes\Red\RedSkin.skin folder

    --
    Milosz


    "WT" wrote:

    > Hello,
    >
    > In my code I set the SkindId for image objects before the Page_Load event
    > for the page.
    > The image is created then added to the control list of an HtmlAnchor object
    > already present in the ascx page.
    > I checked with traces that the skinid is correctlyset, theApp_Theme folder
    > contains the correct Theme whichcontains the Skin, and this last file
    > contain correct path to the gif image placed in a folder under the
    > currenttheme.
    > But no image displayed, looking to the generated source I find <img src=""
    > ......> ?
    > Is thisa known problem ?
    > Any help welcome.
    >
    > CS
    >
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Feb 5, 2007
    #2
    1. Advertising

  3. Thanks for Milosz's input.

    Hi CS,

    As Milosz suggested, you can first check the page's Theme setting to see
    whether the Theme has been applied to the page(in the page directive). Or
    if you want to programmatically apply Theme for your web page, you can use
    Page.PreInit event to do it. e.g.

    void Page_PreInit(object sender, EventArgs e)
    {
    Page.Theme = "themename";
    }

    Here is good article which has described creating and apply Theme for
    ASP.NET 2.0 page

    #Creating Web Application Themes in ASP.NET 2.0
    http://msdn2.microsoft.com/en-us/library/ms379601(VS.80).aspx#themes_topic8

    Please feel free to post here if you have any further questions on this.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================



    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Feb 6, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    12,216
    nguyenxuancanh
    Apr 12, 2008
  2. shapper

    SkinId

    shapper, Sep 22, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    469
    shapper
    Sep 22, 2006
  3. V
    Replies:
    0
    Views:
    383
  4. WT
    Replies:
    14
    Views:
    620
    Walter Wang [MSFT]
    Jun 21, 2007
  5. Joey
    Replies:
    0
    Views:
    734
Loading...

Share This Page