Web custom Control - can't acces image url in Resources folder - vb net

 I'm working on a custom web server control that is suppose to give information on a doctor.  The final goal is to place the control in a hover extender panel, so when you hover over the doctor picture, this control pops up, and play a recording of there voice introducing themself. I'll get to the sound part this weekend.

So far, it seems that all of the references I search are examples for aspx pages. The line in bold are confusing me.

This is a class dll project named teamRoster 

Right now, I'm trying to access a image in the resource folder called BalloonPointer1.gif.  I marked the file embedded in properties. 

I added the assembly info in assemblyinfo.vb
 

<Assembly: System.Web.UI.WebResource("teamRoster.BalloonPointer0.gif", "image/gif")> 
<Assembly: System.Web.UI.WebResource("teamRoster.BalloonPointer1.gif", "image/gif")> 
<Assembly: System.Web.UI.WebResource("teamRoster.UCLABruins.jpg", "image/jpeg")> 
<Assembly: System.Web.UI.WebResource("teamRoster.USCTrojans.jpg", "image/jpeg")> 
 I placed this line of code in my Sub Render to retrieve the image url - Filename = DoctorRoster.vb
  BalloonURL = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "teamRoster.BalloonPointer1.gif"
 This is my DoctorRoster.vb Code page
 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}:DoctorRoster runat=server></{0}:DoctorRoster>")> _
Public Class DoctorRoster
Inherits WebControl

Dim imgImage1 As Image
Dim BalloonURL As String

Sub New
()

MyBase.New()
Me.Width = Unit.Pixel(300)

End Sub <Bindable(True), Category("Field"), DefaultValue(""), Localizable(True)> Property Field_Header() As String

Get
Dim
sField_Header As String = CStr(ViewState("Field_Header"))
If sField_Header Is Nothing Then
Return String
.Empty
Else
Return
sField_Header
End If
End Get

Set
(ByVal Value As String)
ViewState("Field_Header") = Value
End Set

End Property
<Bindable(True), Category("Field"), DefaultValue(""), Localizable(True)> Property Field_Name() As String

Get
Dim
sField_Name As String = CStr(ViewState("Field_Name"))
If sField_Name Is Nothing Then
Return String
.Empty
Else
Return
sField_Name
End If
End Get

Set
(ByVal Value As String)
ViewState("Field_Name") = Value
End Set

End Property
<Bindable(True), Category("Field"), DefaultValue(""), Localizable(True)> Property Field_Graduated() As String

Get
Dim
sField_Graduated As String = CStr(ViewState("Field_Graduated"))
If sField_Graduated Is Nothing Then
Return String
.Empty
Else
Return
sField_Graduated
End If
End Get

Set
(ByVal Value As String)
ViewState("Field_Graduated") = Value
End Set

End Property
<Bindable(True), Category("Field"), DefaultValue(""), Localizable(True)> Property Field_PostGraduate() As String

Get
Dim
sField_PostGraduate As String = CStr(ViewState("Field_PostGraduate"))
If sField_PostGraduate Is Nothing Then
Return String
.Empty
Else
Return
sField_PostGraduate
End If
End Get

Set
(ByVal Value As String)
ViewState("Field_PostGraduate") = Value
End Set

End Property
<Bindable(True), Category("Field"), DefaultValue(""), Localizable(True)> Property Field_Specialty() As String

Get
Dim
sField_Specialty As String = CStr(ViewState("Field_Specialty"))
If sField_Specialty Is Nothing Then
Return String
.Empty
Else
Return
sField_Specialty
End If
End Get

Set
(ByVal Value As String)
ViewState("Field_Specialty") = Value
End Set

End Property
<Bindable(True), Browsable(True), Description("Set Path to Image File"), Category("Field"), DefaultValue(""), Localizable(True)> Property ImageSource() As String

Get
Dim
sImageSource As String = CStr(ViewState("ImageSource"))
If sImageSource Is Nothing Then
Return String
.Empty
Else
Return
sImageSource
End If
End Get

Set
(ByVal Value As String)
ViewState("ImageSource") = Value
End Set

End Property
<Bindable(True), Category("Field"), DefaultValue(True), Localizable(True)> Property XHTML() As Boolean

Get
Dim
sXHTML As String = CStr(ViewState("XHTML"))
If sXHTML Is Nothing Then
Return Boolean
.FalseString
Else
Return Boolean
.TrueString
End If
End Get

Set
(ByVal Value As Boolean)
ViewState("XHTML") = Value
End Set

End Property
<Bindable(True), Category("Field"), DefaultValue(False), Localizable(True)> Property PlaySoundTrack() As Boolean

Get
Dim
sPlaySoundTrack As String = CStr(ViewState("PlaySoundTrack"))
If sPlaySoundTrack Is Nothing Then
Return Boolean
.FalseString
Else
Return Boolean
.TrueString
End If
End Get

Set
(ByVal Value As Boolean)
ViewState("v") = Value
End Set

End Property
<Bindable(True), Category("Field"), DefaultValue(False), Localizable(True)> Property SoundSource() As String

Get
Dim
sSoundSource As String = CStr(ViewState("SoundSource"))
If sSoundSource Is Nothing Then
Return String
.Empty
Else
Return
sSoundSource
End If
End Get

Set
(ByVal Value As String)
ViewState("SoundSource") = Value
End Set

End Property
Protected Overrides Sub
CreateChildControls()

imgImage1 = New Image()
Controls.Add(imgImage1)
imgImage1.ImageUrl = [ImageSource]

MyBase.CreateChildControls()

End Sub
Protected Overrides Sub
RenderContents(ByVal writer As HtmlTextWriter)

If Not Me.Context Is Nothing Then
MyBase
.RenderContents(writer)
End If

End Sub
Protected Overrides Sub
Render(ByVal output As System.Web.UI.HtmlTextWriter)

BalloonURL = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "teamRoster.BalloonPointer1.gif")

If [XHTML] = True Then
With
output
.Write(BalloonURL)
.Write("<table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""300"" style=""border: solid 1px #CCCCCC; background-color: White;"">" & vbCrLf)
.Write(" <tr>" & vbCrLf)
.Write(" <td colspan=""3"" style=""height: 22px;"">" & vbCrLf)
.Write(" <img alt=""Pointer"" src=""" & BalloonURL & """ style=""border: none;"" />" & vbCrLf)
.Write(" </td>" & vbCrLf)
.Write(" </tr>" & vbCrLf)

.Write(" <tr>" & vbCrLf)
.Write(" <td class=""MicroText"" colspan=""3"" style=""padding-left: 20px; text-align: left; background-color: Black; color: White; height: 22px;"" valign=""middle"">" & [Field_Header] & "</td>" & vbCrLf)
.Write(" </tr>" & vbCrLf)
.Write(" <tr>" & vbCrLf)
.Write(" <td rowspan=""4"" valign=""middle"">" & vbCrLf)

EnsureChildControls()
RenderChildren(output)

.Write(" </td>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""text-align: right; padding-right: 5px; width: 90px;"">" & vbCrLf)
.Write(" <span style=""color: gray"">Name:</span>" & vbCrLf)
.Write(" </td>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""text-align: left; padding-left: 5px; width: 160px;"">" & [Field_Name] & "</td>" & vbCrLf)
.Write(" </tr>" & vbCrLf)
.Write(" <tr>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""padding-right: 5px; width: 90px; text-align: right; height: 16px;"">" & vbCrLf)
.Write(" <span style=""color: gray;"">Graduated:</span>" & vbCrLf)
.Write(" </td>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""padding-left: 5px; width: 160px; text-align: left; height: 16px;"">" & Field_Graduated & "</td>" & vbCrLf)
.Write(" </tr>" & vbCrLf)
.Write(" <tr>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""padding-right: 5px; width: 90px; height: 16px; text-align: right"">" & vbCrLf)
.Write(" <span style=""color: gray;"">Post Graduate:</span>" & vbCrLf)
.Write(" </td>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""padding-left: 5px; width: 160px; height: 16px; text-align: left"">" & Field_PostGraduate & "</td>" & vbCrLf)
.Write(" </tr>" & vbCrLf)
.Write(" <tr>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""padding-right: 5px; width: 90px; height: 16px; text-align: right"">" & vbCrLf)
.Write(" <span style=""color: gray"">Specialty:</span>" & vbCrLf)
.Write(" </td>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""padding-left: 5px; width: 160px; height: 16px; text-align: left"">" & [Field_Specialty] & "</td>" & vbCrLf)
.Write(" </tr>" & vbCrLf)
.Write("</table>" & vbCrLf)
End With
Else
With
output
.Write(" <tr>" & vbCrLf)
.Write(" <td colspan=""3"" style=""height: 22px;"">" & vbCrLf)
.Write(" <img alt=""Pointer"" src=""" & BalloonURL & """ style=""border: none;"" />" & vbCrLf)
.Write(" </td>" & vbCrLf)
.Write(" </tr>" & vbCrLf)
.Write(" <tr>" & vbCrLf)

.Write(" <tr>" & vbCrLf)
.Write(" <td class=""MicroText"" colspan=""3"" style=""padding-left: 20px; text-align: left; background-color: Black; color: White; height: 22px;"" valign=""middle"">" & [Field_Header] & "</td>" & vbCrLf)
.Write(" </tr>" & vbCrLf)
.Write(" <tr>" & vbCrLf)
.Write(" <td rowspan=""4"" valign=""middle"">" & vbCrLf)


EnsureChildControls()
RenderChildren(output)

.Write(" </td>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""text-align: right; padding-right: 5px; width: 90px;"">" & vbCrLf)
.Write(" <span style=""color: gray"">Name:</span>" & vbCrLf)
.Write(" </td>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""text-align: left; padding-left: 5px; width: 160px;"">" & [Field_Name] & "</td>" & vbCrLf)
.Write(" </tr>" & vbCrLf)
.Write(" <tr>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""padding-right: 5px; width: 90px; text-align: right; height: 16px;"">" & vbCrLf)
.Write(" <span style=""color: gray;"">Graduated:</span>" & vbCrLf)
.Write(" </td>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""padding-left: 5px; width: 160px; text-align: left; height: 16px;"">" & Field_Graduated & "</td>" & vbCrLf)
.Write(" </tr>" & vbCrLf)
.Write(" <tr>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""padding-right: 5px; width: 90px; height: 16px; text-align: right"">" & vbCrLf)
.Write(" <span style=""color: gray;"">Post Graduate:</span>" & vbCrLf)
.Write(" </td>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""padding-left: 5px; width: 160px; height: 16px; text-align: left"">" & Field_PostGraduate & "</td>" & vbCrLf)
.Write(" </tr>" & vbCrLf)
.Write(" <tr>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""padding-right: 5px; width: 90px; height: 16px; text-align: right"">" & vbCrLf)
.Write(" <span style=""color: gray"">Specialty:</span>" & vbCrLf)
.Write(" </td>" & vbCrLf)
.Write(" <td class=""MicroText"" style=""padding-left: 5px; width: 160px; height: 16px; text-align: left"">" & [Field_Specialty] & "</td>" & vbCrLf)
.Write(" </tr>" & vbCrLf)
.Write("</table>" & vbCrLf)
End With
End If
End Sub

End Class
  
  
  

 

0
jkirkerx
2/29/2008 9:24:01 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

2 Replies
782 Views

Similar Articles

[PageSpeed] 40

I am having the same issue. so is there any solution to this problem? How can I retrieve the image from the resources folder?

0
siegblazer
12/10/2008 9:31:39 AM

 Turns out you can't access images in the resource folder in vb, but you can in Csharpe.  Images have to be places in the root folder of your project, and marked as embedded in order to access them in vb. Don't use the above as an example, it's completly wrong in structure and syntax. I had no clue what I was doing at the time because I was a newbie.

0
jkirkerx
12/10/2008 6:26:59 PM
Reply:

Similar Artilces:

Add .Net Control to Web Custom Control
 I want to add .NET Control (like: TextBox, Button...) to Web Custom Control.How i can do it? Alphavn That's called a composite control -- "Mark As Answer" if my reply helped you -- Hello Guys What gunteman said, that is one approach and in most cases the right one.But its also possible to add child controls to a Control thats inherit from WebControl itself. Be sure to implement INamingContainer to that inherited Control too, thats the important point of that approach.--Microsoft MVP - Visual Developer ASP / ASP.NET- http://www.aspnetzone.de/blogs/peterbuch...

Web Custom Control within a Web Custom Control
I was wondering if this can be done and how. I've created a simple custom control that displays a header which is my first custom control. So I'm just a baby when it comes to this.. Within the header I currently have a property for breadcrumbs which is a string. What I would like to do is have the breadcrumb property  be a Link Button List. I did find a custom control of a Link Button List which is exactly what I wanted. My question is how can/do  I include this into my custom control? Can it done? How? Please help? I'm at a lose here.   Susan You should be able to do ...

Is it possible to have a web custom control( not a user control) in the app_code folder of a web project?
Or must it be inside a class library by itself? Do you compile the web site to get the dll then add that to the toolbar? Yes you can find the info here:http://alpascual.com/blog/al/archive/2006/06/19/The-power-of-CompositeControl.-Another-skeleton-class-.aspxCheersAlMy BlogMapStats.NETPlease click on 'Mark as Answer' if this post answered your question! Sorry, I'm not following. What does extending a composite control illustrate about creating a custom web control inside the appcode folder of web project....

Cann't add the reference ' System.Web.UI' from ".NET"
Cann't add the reference ' System.Web.UI' from ".NET",and i can n't find the file "System.web.UI.dll" from the "C:\WINDOWS\Microsoft.NET\Framework",so anyone can help me solve it thanks there is a no-footbird.the wind is its nest.it never stops flying until it dies... System.Web.UI is namespace, not an assembly. Add "System.Web.dll" and that will include System.Web.UI.Cheers,       Kevin JonesMy Blog Is your project a web project? To me, it looks like missing system.web.dll in your reference I think you need to reference system.web in the References...

custom web user control and web form
Guys,          I am trying to develop a context menu control for all of my pages. what i am trying to do is that i want the control to pick a datasource from the markup and then check whether its an xml file or a datatable. I created a class called datasource.   /**************************DataSource Class****************************/  public class DataSource { /// <summary> /// This is to identify unique elements from the markup /// </summary>protected string _ID; /// <summary> /// This will be the Datasource ID e...

Custom Web Control inside another Custom Web Control
Hi I created a custom web control (CusWebNew) that displays some textboxes by adding them to the ControlCollection of the webcontrol. I also created a custom webcontrol (CustWebButton) that inherts from Button control, and overrided the OnClick function. When I use CustWebButton on a regular web form, it seems to function correctly. However, when I added to be part of the ControlCollection of CustWebNew, it stops to work.   Any ideas why? Thanks Hey, What do you mean by stops to work?  Explain what you are trying to do with it and what it doesn't do.Brian"Trust in the...

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

WDP for VS2008 still doesn't allow web.config file section replacement of 'System.Net'
There were a series of posts on various blogs about the VS 2005 version of the WDP not allowing replacement of the 'System.Net' section. This was a rather significant oversight, in my opinion, as the three parts of web.config you would most likely want to replace would be appSettings for site specific attributes, connectionStrings for the proper database configuration, and System.Net to set up site-generated email. That being said, there was talk in the forums about fixing for the next release. Indeed, in the release notes for WDP for 2008 there was mention of fixes for config file u...

.Net Web Form & Web Service Deployment
Hi all I have written some test web services and some web form applications and deployed them to my IIS. That's fine but I now want to deploy them to my real IIS server. I have created an msi for each but the problem is I seem to only be able to deploy to the default web site. Our default web site is turned off and instead we use several other sites. Does anybody happen to if Powerbuilder 11 supports non default web sites? If not do I need to hack the msi and if so can anybody suggest a suitable tool. I have Orca but it's not very friendly. Unless of course I knew exactly w...

I cannot drag web custom controls from toolbox to web form
I have created some web custom controls (both composite controls or derived/inherited controls).  I successfully added them to the toolbox. However, when I try to drag them onto the form, the cursor changes into a black circle with a diagonal line, and cannot drag them.  I also tried double-clicking them from the toolbox but it still won't work. I sent the Control Library (DLL) to a friend, and he managed to use it properly.  I am assuming this is a problem with my Visual Studio. Has anyone encountered such a problem?  Any suggestions or solutions?   Thanks. I...

.Net Windows Control in Web Form
Hi all,How can I use a .Net windows control in a web form? I use object tag but it doesn't work and displays empty.Thanks in advance cheers Hi, you can check this article out: Hosting a Windows Control in a Web Form. This shows only how to host the control. If you want interaction with the client you can do this by setting the correct CAS (Code Access Security) settings on the client pc. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. Thanks guys for your replycheers...

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

Reusing custom web control in the same web control
Hello, I'm newbie in web development and of course asp.net. I am actually trying to build my first page and I'd like to know if it is possible to make a custom webcontrol that will contain itself. Let's say I want to draw a folder hierarchy in treeview-like structure. I thought I could make a control that will display a folder and if this folder contains subfolders then for each the control will include itself. Is this even possible? What would you suggest me to do to? Thanks in advance. TomTom Hagen http://thagen.dteam.info If the control can have child controls, then I s...

Cant drag-and-drop Web Custom Control to Web Form!
Hi,I'm going insane here, I've read countless articles how to create a Web Custom Control and add it to the Toolbox and then just Drag-and-Drop it to a Web Form.And I have done exactly that except for the last step, any Web Custom Control I create refuses to be Drag-and-Dopped to the Web Form. What happens is the following, after I have added the Web Custom Control to the ToolBox I click it and drag it to the Web Form designer area. First I can see the icon of the Web Custom Control and I see a Referance being created but just after that the icon changes to one of those "you cant park here s...

"Visual Studio .NET cannot create or open the application. Web site 'http://localhost/2373/Labs/Lab071' not started on this Web server. "
i wanted to create a New Project, with Visual Basic Projects as Project Type, and ASP.NET Web Application as the selected Templates. However, there was an error message pop up saying these: "Visual Studio .NET cannot create or open the application. Web site 'http://localhost/2373/Labs/Lab071' not started on this Web server. " How may i overcome it? Is 2373 already a directory in your web root? How about Labs? It might have something to do with subdirectories, have you tried creating one just off the route? Ala: http://localhost/labs071 ? You might want to try to see if tha...

Web resources about - Web custom Control - can't acces image url in Resources folder - vb net - asp.net.web-forms

Resources last updated: 12/23/2015 7:11:18 AM