SkinID not working for images

W

WT

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
 
G

Guest

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
 
S

Steven Cheng[MSFT]

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top