insert message with overrides

T

TJS

I want to insert a message with an override if a condition exists but the
overrides does not kick in.
How do I invoke the overrides to display a message from my class code?

============Overrides code================
Protected Overrides Sub Render(writer As HtmlTextWriter)

if Application("idx") = true then
Dim vMessage As String = "message goes here"

'*** Render the page and retrieve into StringBuilder
Dim sb As New StringBuilder()
Dim hWriter As New HtmlTextWriter(New StringWriter(sb))
MyBase.Render(hWriter)

' *** store to a string
Dim PageResult As String = sb.ToString()
Dim At As Integer = PageResult.ToLower().LastIndexOf("")

If At > - 1 Then
PageResult = PageResult.Insert(At, vMessage)
End If

' *** Write it back to the server
writer.Write(PageResult)
end if

Return

End Sub 'Render
 
G

Guest

Hi

I assume the code that you have sent is of a custom control that you are trying to build

So as you know the custom controls gets bundled in to a separate Assembly and to use them you have to register the
in the page that you use it

So this assembly knows nothing of the HttpContext

Try doing out this

1> Include the namespace System.Web

2> When you want to access the Application variables use the following
HttpContext.Current.Application(VarName

i hope this should solve your problem

Let me know on this
 
T

TJS

it was the HttpContext thingy

thanks


kashypa said:
Hi,

I assume the code that you have sent is of a custom control that you are trying to build.

So as you know the custom controls gets bundled in to a separate Assembly
and to use them you have to register them
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top