Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RenderControl and HTMLTextWriter in VB Class

Status
Not open for further replies.

sifitz

Programmer
Feb 27, 2002
47
0
0
GB
I am trying to dynamically change properties on an Image and then render the image to the browser. RenderControl looks like it would do the trick but I can't figure out how to use the HTMLTextWriter.

If possible, I would also like perform some functionality like Response.Write but this doesn't appear to work from a class.

The two pieces ofCode that I have tried to use
Code:
'=========================

Sub WriteImage()
    Dim m_imgRightLogo As System.Web.UI.WebControls.Image

    m_imgRightLogo = New System.Web.UI.WebControls.Image()
    m_imgRightLogo.ImageUrl = "img/logo.gif"
    m_imgRightLogo.AlternateText = "This is the main logo"

    'This is where the problem is - Object reference not set to an instance of an object
    Dim wrtrHTML As HtmlTextWriter
    m_imgRightLogo.RenderControl(wrtrHTML)
End Sub

'=========================

Sub WriteText()
    'Error here - Name response is not declared
    Response.Write("Here is Some text")
End Sub

Can somebody please explain how to do this?

Thanks Si.

[afro]
 
Thanks John,
I tried using the New keyword and I got an error saying that I had the wrong number of arguments so I tried adding an argument which needed to be of type System.IO.TextWriter

So I tried declaring a Textwriter and got more trouble:-
Code:
Dim wrtrText As New System.IO.TextWriter()
Dim wrtrHTML As New HtmlTextWriter(wrtrText)
m_imgRightLogo.RenderControl(wrtrHTML)

This Code gave me error New cannot be used on a class that is declared as MustInherit

I just can't find decent examples on how this works.

[afro]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top