SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Strategy asp.net Embedded Resources

    I trying to reduce my time spent deploying a site.. by putting everything in a dll.

    so far i have two icons: delete, edit
    and haven't been able to render them.

    AssemblyInfo.cs
    PHP Code:
    [assemblyWebResourceAttribute("RobustHaven.Components.KnowledgeBase.ClientResources.Themes.Default.Icons.delete.png""image/png")]
    [
    assemblyWebResourceAttribute("RobustHaven.Components.KnowledgeBase.ClientResources.Themes.Default.Icons.edit.png""image/png")] 

    The dll which they are embedded in is: RobustHaven.Components.KnowledgeBase


    in the aspx page i have:
    PHP Code:
                        <img src="<%=Page.ClientScript.GetWebResourceUrl(GetType(), "RobustHaven.Components.KnowledgeBase.ClientResources.Themes.Default.Icons.delete.png") %>" alt="delete" /> 

    basically the url it generates creates a 404 http error.
    what is the implementation of GetWebResourceUrl so i can manually create a url to the embedded resource?
    I wish it would throw an exception.. but nope just doesn't render anything ... i can put anything in the string portion and still no exception.


    url it creates:
    PHP Code:
    /WebResource.axd?d=qqJ8tjv5pMksPMk76RazplV9lffvnnyCHzcis9J-qArr8SQ-ynYtpfHwX35K_6fGnV6T0GzlEdgVWGWxJjQ01ioRrZk83-yDV85aZ9GzFUoBmZHKQFtMYe3evLbP3Cm210PzJo3M38Py9PaUexcqF5ST7Ko4jQY8nGsvsH5l0HM1&t=633421634875625000 
    /WebResource.axd by itself generates 404 error

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Figured it out....

    PHP Code:
                        <img src='<%=Page.ClientScript.GetWebResourceUrl(typeof(RobustHaven.Components.KnowledgeBase.ArticlesGridView), "RobustHaven.Components.KnowledgeBase.ClientResources.Themes.Default.Icons.delete.png") %>' alt="delete" /> 
    basically for typeof pick any object inside your assembly which contains the web resources.


    but since i wanted a strategy....
    The final version is going be a custom delete image control that inherits from the asp image control where on render i'll attach the correct url. This way theme can be managed internal to the knowledgebase.dll and user can just drag drop the delete image control. without having to do anything in the codebehind on trying to manage themes for components.


    final
    PHP Code:
    using System;

    namespace 
    RobustHaven.Components.KnowledgeBase.ClientControls
    {
        public class 
    DeleteImageButton System.Web.UI.WebControls.ImageButton
        
    {
            protected 
    override void Render(System.Web.UI.HtmlTextWriter writer)
            {
                
    this.AlternateText "Delete";
                
    this.ImageUrl Page.ClientScript.GetWebResourceUrl(
                    
    typeof(RobustHaven.Components.KnowledgeBase.ClientControls.DeleteImageButton), // can be any control in this assembly
                    
    String.Format("RobustHaven.Components.KnowledgeBase.ClientResources.Themes.{0}.Icons.delete.png"ClientControls.UserProfile.Instance.Theme )
                );

                
    base.Render(writer);
            }
        }
    }



    // my gridview
                    
    <asp:TemplateField ShowHeader="False">
                        <
    ItemTemplate>
                            <
    KnowledgeBase:DeleteImageButton CommandName="Delete" runat="server" />
                            <
    asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                                
    CommandName="Delete" Text="Delete"></asp:LinkButton>
                        </
    ItemTemplate>
                    </
    asp:TemplateField
    Last edited by leblanc; Mar 28, 2008 at 23:06.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •