Can I have a webcontrol push an image

G

GADOI

Hello:
The objective is a dll with embeded images that when the dll is called from
an aspx web page, it returns a table with pictures. So, I do not want to
call the image from the aspx web page but rather have the dll push the image
to the web page.

When I attempt to reference the image from the dll (WebControl) I get the
error: Object reference not set to an instance of an object.
The imge Help.gif is embeded and is located in a folder called Images.
===================================================================
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
<Assembly:
WebResource("GAINSCOMwebdocument.WebDocumentControl.Images.Help.gif",
"img/gif")>
<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1
runat=server></{0}:WebCustomControl1>")> _
Public Class WebDocumentControl
Inherits WebControl
<Bindable(True), Category("Appearance"), DefaultValue(""),
Localizable(True)> Property Text() As String
Get
Dim s As String = CStr(ViewState("Text"))
If s Is Nothing Then
Return String.Empty
Else
Dim Var_ImageUrl As String = ""
Dim Var_Error As String = ""
Try
Var_ImageUrl =
Page.ClientScript.GetWebResourceUrl(GetType(System.String),
"GAINSCOMwebdocument.WebDocumentControl.Images.Help.gif")
Catch ex As Exception
Var_Error = ex.Message
End Try

Return "<table bgcolor='#78987'><tr><td>" + s + "</td><td>"
+ Var_Error + "</td><td><img src='" + Var_ImageUrl + "'></td></tr></table>"
End If
End Get

Set(ByVal Value As String)
ViewState("Text") = Value
End Set
End Property
Protected Overrides Sub RenderContents(ByVal output As HtmlTextWriter)
output.Write(Text)
End Sub
===================================================================
Any thoughts ?
Thanks
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top