Hello everybody skinplayer.jpg the image is at the root of my WebCustomControl (Asp.Net Server Control) setada on your property to Embedded Resource BuildAction, just another picture on this. bmp and that is also set with Embedded Resource, but with the
name of the class of control (this img to be used as 16x16 icon in the toolbox) meucontrole.bmp
In the case of the icon image or meucontrole.bmp it usually recognizes the toolbox icon in design mode when I add the dll of the control in VS2008
Already skinplayer.jpg image that is in my design class as below
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.Design;
namespace NetControl
{
class PlayerDesigner:ControlDesigner
{
private YouTubePlayerControl _minhasmart;
public override void Initialize(System.ComponentModel.IComponent component)
{
base.Initialize(component);
_minhasmart = (PlayerControl)component;
}
private DesignerActionListCollection lista = null;
public override DesignerActionListCollection ActionLists
{
get
{
if (lista == null)
{
lista = base.ActionLists;
lista.Add(new SmartTag((PlayerControl)Component));
}
return lista;
}
}
public override string GetDesignTimeHtml()
{
string imgurl = "~/skinplayeroficialcopyright484.jpg";
PlayerControl control = (PlayerControl)Component;
StringBuilder sb = new StringBuilder();
sb.AppendFormat("<img alt=\"PlayerControl_{0}\"",control.ID);
sb.AppendFormat("src=\"{0}\"/>",imgurl);
return sb.ToString();
}
}
}
When I drag my control from the toolbox to the aspx page in design view of my VS2008 it appears in fact a square with an x that is empty without that image in my root webcustomcontrol and set with the Embedded Resource
How do I fix this so when you drag the control to my page in design mode tb this image set with the Embedded Resource to appear in aspx page in design view of my VS2008?
If someone can guide me now thank you
translated from Portuguese into English by google translator
Ok see if following the steps below and the code did WebResource it is correct in my class to design after making the build of control to make sure that the image of the class will appear along with the DLL in design mode the user or client to download my
WebCustomControl
Well here's the steps I did:
STEP 1 - Within my VS2008, when you click the Properties folder of my control with the right mouse button in TAB Resources, created a resource early and then
AddResource> newImage> JPGimage, giving a name for the new feature in the text box that opened the window, and thus created the Resources folder in my WebCustomControl with image inside
STEP 2 - Clicking on this image to select it properties within the Resources Tab, I changed the property to Embedded in.resx Persistence
STEP 3 - Clicking on image created within the Resources folder, clicking the Property BuildAction it moved to Embedded Resource
STEP 4 - Inside AssemblyInfo.cs, pulp properties added this line to my image
STEP 5 - In my ClassDesigner.cs added the following code in GetDesignTimeHtml method
Okseeiffollowingthe stepsbelowand thecodedidWebResourceit is correctinmyclasstodesignaftermakingthe buildofcontrolto make surethat theimage ofthe classwillappearalongwiththe DLLindesign modetheuserorclientto downloadmyWebCustomControl
Now
openedat that timebut
thefirst
linkdid notopen
ortrafficmust be
someproblemserver connectionand
taking advantage
of thesite..
just tocompletethe steps above
mydoubts
thatI postedtoo
correct?
imgurl.Replace("~", "") - only the server can translate and process the ~
Here's the smallest working exaple of a control that I have. This is the very basics of a control that works, and a model to base your future contols off of.
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
<DefaultProperty("Text"), ToolboxData("<{0}:Display_EmbeddedHeader runat=server></{0}:Display_EmbeddedHeader>")> _
Public Class Display_EmbeddedHeader
Inherits WebControl
Private Panel As Panel
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
If Not Me.Context Is Nothing Then
RenderContents(writer)
Else
RenderDesignMode(writer)
End If
End Sub
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
MyBase.OnInit(e)
Controls.Clear()
Dim cs As ClientScriptManager = Me.Page.ClientScript
Dim rsType As Type = Me.GetType()
Dim Comment As LiteralControl
Comment = New LiteralControl
Comment.Text = "<!-- Internet Commerce Engine 5 Display_EmbeddedHeader Control V1.4.2 for ASP.NET -->" & vbCrLf
Controls.Add(Comment)
Panel = New Panel
With Panel
.ID = [ID] & "_EmbeddedHeader"
.Width = 960
.Style.Add(HtmlTextWriterStyle.Width, "960px")
.Style.Add(HtmlTextWriterStyle.TextAlign, "center")
.Style.Add(HtmlTextWriterStyle.Margin, "0px auto")
End With
Controls.Add(Panel)
Dim table_Header As Table
table_Header = New Table
With table_Header
.CellPadding = 0
.CellSpacing = 0
.Width = 960
.Height = 65
.Style.Add(HtmlTextWriterStyle.Width, "960px")
.Style.Add(HtmlTextWriterStyle.Width, "65px")
End With
Panel.Controls.Add(table_Header)
Dim tr_Header As TableRow
tr_Header = New TableRow
With tr_Header
End With
table_Header.Controls.Add(tr_Header)
Dim td_Header As TableCell
td_Header = New TableCell
With td_Header
'.CssClass = "DefaultHeader"
.Width = [Width]
.Height = 65
.Style.Add(HtmlTextWriterStyle.Width, [Width].ToString)
.Style.Add(HtmlTextWriterStyle.Height, "65px")
.VerticalAlign = VerticalAlign.Middle
End With
tr_Header.Controls.Add(td_Header)
Dim img_header As Image
img_header = New Image
With img_header
.ImageAlign = ImageAlign.AbsMiddle
.ImageUrl = cs.GetWebResourceUrl(rsType, "Admin_Standard.Header-TestDrive-Right.gif")
End With
td_Header.Controls.Add(img_header)
End Sub
Private Sub RenderDesignMode(ByVal writer As HtmlTextWriter)
Controls.Clear()
Dim cs As ClientScriptManager = Me.Page.ClientScript
Dim rsType As Type = Me.GetType()
Dim Comment As LiteralControl
Comment = New LiteralControl
Comment.Text = "<!-- Internet Commerce Engine 5 Display_EmbeddedHeader Control V1.4.2 for ASP.NET -->" & vbCrLf
Controls.Add(Comment)
Panel = New Panel
With Panel
.ID = [ID] & "_EmbeddedHeader"
.Width = 960
.Style.Add(HtmlTextWriterStyle.Width, "960px")
.Style.Add(HtmlTextWriterStyle.TextAlign, "center")
.Style.Add(HtmlTextWriterStyle.Margin, "0px auto")
End With
Controls.Add(Panel)
Dim table_Header As Table
table_Header = New Table
With table_Header
.CellPadding = 0
.CellSpacing = 0
.Width = 960
.Height = 65
.Style.Add(HtmlTextWriterStyle.Width, "960px")
.Style.Add(HtmlTextWriterStyle.Width, "65px")
End With
Panel.Controls.Add(table_Header)
Dim tr_Header As TableRow
tr_Header = New TableRow
With tr_Header
End With
table_Header.Controls.Add(tr_Header)
Dim td_Header As TableCell
td_Header = New TableCell
With td_Header
'.CssClass = "DefaultHeader"
.Width = [Width]
.Height = 65
.Style.Add(HtmlTextWriterStyle.Width, [Width].ToString)
.Style.Add(HtmlTextWriterStyle.Height, "65px")
.VerticalAlign = VerticalAlign.Middle
End With
tr_Header.Controls.Add(td_Header)
Dim img_header As Image
img_header = New Image
With img_header
.ImageAlign = ImageAlign.AbsMiddle
.ImageUrl = cs.GetWebResourceUrl(rsType, "Admin_Standard.Header-TestDrive-Right.gif")
End With
td_Header.Controls.Add(img_header)
Panel.RenderControl(writer)
End Sub
<Bindable(True)> _
<Category("Appearance")> _
<DefaultValue("")> _
<Localizable(True)> Property CssStyle_Text() As String
Get
Dim s As String = CStr(ViewState("CssStyle_Text"))
If s Is Nothing Then
Return String.Empty
Else
Return s
End If
End Get
Set(ByVal Value As String)
ViewState("CssStyle_Text") = Value
End Set
End Property
End Class
LuizIta
Member
21 Points
99 Posts
How to Display the image you'll be on my my WebControl Class Designer Embedded Resource using the...
Jan 01, 2011 08:51 PM|LINK
Hello everybody skinplayer.jpg the image is at the root of my WebCustomControl (Asp.Net Server Control) setada on your property to Embedded Resource BuildAction, just another picture on this. bmp and that is also set with Embedded Resource, but with the name of the class of control (this img to be used as 16x16 icon in the toolbox) meucontrole.bmp
In the case of the icon image or meucontrole.bmp it usually recognizes the toolbox icon in design mode when I add the dll of the control in VS2008
Already skinplayer.jpg image that is in my design class as below
using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.Design; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.Design; namespace NetControl { class PlayerDesigner:ControlDesigner { private YouTubePlayerControl _minhasmart; public override void Initialize(System.ComponentModel.IComponent component) { base.Initialize(component); _minhasmart = (PlayerControl)component; } private DesignerActionListCollection lista = null; public override DesignerActionListCollection ActionLists { get { if (lista == null) { lista = base.ActionLists; lista.Add(new SmartTag((PlayerControl)Component)); } return lista; } } public override string GetDesignTimeHtml() { string imgurl = "~/skinplayeroficialcopyright484.jpg"; PlayerControl control = (PlayerControl)Component; StringBuilder sb = new StringBuilder(); sb.AppendFormat("<img alt=\"PlayerControl_{0}\"",control.ID); sb.AppendFormat("src=\"{0}\"/>",imgurl); return sb.ToString(); } } }When I drag my control from the toolbox to the aspx page in design view of my VS2008 it appears in fact a square with an x that is empty without that image in my root webcustomcontrol and set with the Embedded Resource
How do I fix this so when you drag the control to my page in design mode tb this image set with the Embedded Resource to appear in aspx page in design view of my VS2008?
If someone can guide me now thank you
translated from Portuguese into English by google translator
Smrutis_mind...
Member
644 Points
120 Posts
Re: How to Display the image you'll be on my my WebControl Class Designer Embedded Resource using...
Jan 03, 2011 09:48 AM|LINK
I think the problem is in the 'imagUrl' .
It is unable to get the image at the perticular place when the UserControl is dragged into a page.
Smruti Ranjan Sahoo
Mindfire Solutions Pvt Ltd
[Please mark it as answer if you are satisfied with the answer.]
LuizIta
Member
21 Points
99 Posts
Re: How to Display the image you'll be on my my WebControl Class Designer Embedded Resource using...
Jan 03, 2011 05:46 PM|LINK
Ok see if following the steps below and the code did WebResource it is correct in my class to design after making the build of control to make sure that the image of the class will appear along with the DLL in design mode the user or client to download my WebCustomControl
Well here's the steps I did:
STEP 1 - Within my VS2008, when you click the Properties folder of my control with the right mouse button in TAB Resources, created a resource early and then
AddResource> newImage> JPGimage, giving a name for the new feature in the text box that opened the window, and thus created the Resources folder in my WebCustomControl with image inside
STEP 2 - Clicking on this image to select it properties within the Resources Tab, I changed the property to Embedded in.resx Persistence
STEP 3 - Clicking on image created within the Resources folder, clicking the Property BuildAction it moved to Embedded Resource
STEP 4 - Inside AssemblyInfo.cs, pulp properties added this line to my image
STEP 5 - In my ClassDesigner.cs added the following code in GetDesignTimeHtml method
Ok see if following the steps below and the code did WebResource it is correct in my class to design after making the build of control to make sure that the image of the class will appear along with the DLL in design mode the user or client to download my WebCustomControl
Well here's the steps I did:
STEP 1 - Within my VS2008, when you click the Properties folder of my control with the right mouse button in TAB Resources, created a resource early and then
AddResource> newImage> JPGimage, giving a name for the new feature in the text box that opened the window, and thus created the Resources folder in my WebCustomControl with image inside
STEP 2 - Clicking on this image to select it properties within the Resources Tab, I changed the property to Embedded in.resx Persistence
STEP 3 - Clicking on image created within the Resources folder, clicking the Property BuildAction it moved to Embedded Resource
STEP 4 - Inside AssemblyInfo.cs, pulp properties added this line to my image
STEP 6 - Build on WebControl
STEP 7 - When testing after putting in the Toolbox and add the control on aspx page from a projetoteste that is in the same project directory in my SolutionExplorer of VS2008, it worked, showing the image in design view the image from my supervision
What I wonder is this correct the above steps can be confident that the same has happened in my test will happen to users who download my WebControl
And while you can create one. msi executable with a WebCustomControl WebSetupProject?
I'm waiting and I thank you
Translated from Portuguese into English with Google Translator
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: How to Display the image you'll be on my my WebControl Class Designer Embedded Resource using...
Jan 04, 2011 07:15 AM|LINK
Hi LuizIta,
Here is the solution for Using Image as Embedded Resource for ASP.NET CustomControl:
http://geekswithblogs.net/shahed/archive/2008/04/12/121211.aspx
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework
LuizIta
Member
21 Points
99 Posts
Re: How to Display the image you'll be on my my WebControl Class Designer Embedded Resource using...
Jan 04, 2011 12:41 PM|LINK
Two final doubts the link you gave me is with broken link and could not see giving page not displayed and the steps I posted above are correct?
I'm waiting and I thank you
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: How to Display the image you'll be on my my WebControl Class Designer Embedded Resource using...
Jan 05, 2011 01:11 AM|LINK
Hi LuizIta,
I am not sure why you cannot see the page, which opens well.
http://geekswithblogs.net/shahed/archive/2008/04/12/121211.aspx
http://www.karpach.com/Custom-ASP-NET-server-control-with-embedded-resources.htm
http://weblogs.asp.net/gurusarkar/archive/2010/12/10/custom-control-and-embedded-css-and-images.aspx
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework
LuizIta
Member
21 Points
99 Posts
Re: How to Display the image you'll be on my my WebControl Class Designer Embedded Resource using...
Jan 05, 2011 03:24 AM|LINK
Now opened at that time but the first link did not open or traffic must be some problem server connection and taking advantage of the site .. just to complete the steps above my doubts that I posted too correct?
I'm waiting and I thank you
Sorry had translated pro African by google this right now laughs ..
jkirkerx
Contributor
3750 Points
873 Posts
Re: How to Display the image you'll be on my my WebControl Class Designer Embedded Resource using...
Jan 22, 2011 04:32 AM|LINK
imgurl.Replace("~", "") - only the server can translate and process the ~
Here's the smallest working exaple of a control that I have. This is the very basics of a control that works, and a model to base your future contols off of.
Imports System Imports System.Collections.Generic Imports System.ComponentModel Imports System.Text Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls <DefaultProperty("Text"), ToolboxData("<{0}:Display_EmbeddedHeader runat=server></{0}:Display_EmbeddedHeader>")> _ Public Class Display_EmbeddedHeader Inherits WebControl Private Panel As Panel Protected Overrides Sub Render(ByVal writer As HtmlTextWriter) If Not Me.Context Is Nothing Then RenderContents(writer) Else RenderDesignMode(writer) End If End Sub Protected Overrides Sub OnInit(ByVal e As System.EventArgs) MyBase.OnInit(e) Controls.Clear() Dim cs As ClientScriptManager = Me.Page.ClientScript Dim rsType As Type = Me.GetType() Dim Comment As LiteralControl Comment = New LiteralControl Comment.Text = "<!-- Internet Commerce Engine 5 Display_EmbeddedHeader Control V1.4.2 for ASP.NET -->" & vbCrLf Controls.Add(Comment) Panel = New Panel With Panel .ID = [ID] & "_EmbeddedHeader" .Width = 960 .Style.Add(HtmlTextWriterStyle.Width, "960px") .Style.Add(HtmlTextWriterStyle.TextAlign, "center") .Style.Add(HtmlTextWriterStyle.Margin, "0px auto") End With Controls.Add(Panel) Dim table_Header As Table table_Header = New Table With table_Header .CellPadding = 0 .CellSpacing = 0 .Width = 960 .Height = 65 .Style.Add(HtmlTextWriterStyle.Width, "960px") .Style.Add(HtmlTextWriterStyle.Width, "65px") End With Panel.Controls.Add(table_Header) Dim tr_Header As TableRow tr_Header = New TableRow With tr_Header End With table_Header.Controls.Add(tr_Header) Dim td_Header As TableCell td_Header = New TableCell With td_Header '.CssClass = "DefaultHeader" .Width = [Width] .Height = 65 .Style.Add(HtmlTextWriterStyle.Width, [Width].ToString) .Style.Add(HtmlTextWriterStyle.Height, "65px") .VerticalAlign = VerticalAlign.Middle End With tr_Header.Controls.Add(td_Header) Dim img_header As Image img_header = New Image With img_header .ImageAlign = ImageAlign.AbsMiddle .ImageUrl = cs.GetWebResourceUrl(rsType, "Admin_Standard.Header-TestDrive-Right.gif") End With td_Header.Controls.Add(img_header) End Sub Private Sub RenderDesignMode(ByVal writer As HtmlTextWriter) Controls.Clear() Dim cs As ClientScriptManager = Me.Page.ClientScript Dim rsType As Type = Me.GetType() Dim Comment As LiteralControl Comment = New LiteralControl Comment.Text = "<!-- Internet Commerce Engine 5 Display_EmbeddedHeader Control V1.4.2 for ASP.NET -->" & vbCrLf Controls.Add(Comment) Panel = New Panel With Panel .ID = [ID] & "_EmbeddedHeader" .Width = 960 .Style.Add(HtmlTextWriterStyle.Width, "960px") .Style.Add(HtmlTextWriterStyle.TextAlign, "center") .Style.Add(HtmlTextWriterStyle.Margin, "0px auto") End With Controls.Add(Panel) Dim table_Header As Table table_Header = New Table With table_Header .CellPadding = 0 .CellSpacing = 0 .Width = 960 .Height = 65 .Style.Add(HtmlTextWriterStyle.Width, "960px") .Style.Add(HtmlTextWriterStyle.Width, "65px") End With Panel.Controls.Add(table_Header) Dim tr_Header As TableRow tr_Header = New TableRow With tr_Header End With table_Header.Controls.Add(tr_Header) Dim td_Header As TableCell td_Header = New TableCell With td_Header '.CssClass = "DefaultHeader" .Width = [Width] .Height = 65 .Style.Add(HtmlTextWriterStyle.Width, [Width].ToString) .Style.Add(HtmlTextWriterStyle.Height, "65px") .VerticalAlign = VerticalAlign.Middle End With tr_Header.Controls.Add(td_Header) Dim img_header As Image img_header = New Image With img_header .ImageAlign = ImageAlign.AbsMiddle .ImageUrl = cs.GetWebResourceUrl(rsType, "Admin_Standard.Header-TestDrive-Right.gif") End With td_Header.Controls.Add(img_header) Panel.RenderControl(writer) End Sub <Bindable(True)> _ <Category("Appearance")> _ <DefaultValue("")> _ <Localizable(True)> Property CssStyle_Text() As String Get Dim s As String = CStr(ViewState("CssStyle_Text")) If s Is Nothing Then Return String.Empty Else Return s End If End Get Set(ByVal Value As String) ViewState("CssStyle_Text") = Value End Set End Property End Class