S
Strange Cat
Hi everyone!
I am trying to write some "auto-translating" components for an ASP.NET
intranet application.
I started inheriting from label and a made a small control. Also i tested on
the button, they work OK, but I have a question: here is the short code for
the btwButton i made:
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Resources
<DefaultProperty("Text"), ToolboxData("<{0}:btwButton
runat=server></{0}:btwButton>")> Public Class btwButton
Inherits System.Web.UI.WebControls.Button
Private Function TranslateText(ByVal toTranslate As String) As String
Dim r As ResourceManager
Try
r = Page.Application("Translator")
Return r.GetString(toTranslate)
Catch ex As System.Exception
Return toTranslate
End Try
End Function
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
[Text] = TranslateText([Text]) <<<<< [Text] changes are lost
MyBase.Render(output)
End Sub
End Class
It works as I want, but i'd like to know why the Text property changes after
the first Render are lost, and the next time it renders the control it
returns to the Text property i set in design mode. To make it clear, i'm
happy with this behaviour, but I'd like to know why the Text property gets
resetted to the designtime value... Just in case i'm doing something real
wrong, i'm new to inheriting controls and so on...
TIA
ASC
I am trying to write some "auto-translating" components for an ASP.NET
intranet application.
I started inheriting from label and a made a small control. Also i tested on
the button, they work OK, but I have a question: here is the short code for
the btwButton i made:
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Resources
<DefaultProperty("Text"), ToolboxData("<{0}:btwButton
runat=server></{0}:btwButton>")> Public Class btwButton
Inherits System.Web.UI.WebControls.Button
Private Function TranslateText(ByVal toTranslate As String) As String
Dim r As ResourceManager
Try
r = Page.Application("Translator")
Return r.GetString(toTranslate)
Catch ex As System.Exception
Return toTranslate
End Try
End Function
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
[Text] = TranslateText([Text]) <<<<< [Text] changes are lost
MyBase.Render(output)
End Sub
End Class
It works as I want, but i'd like to know why the Text property changes after
the first Render are lost, and the next time it renders the control it
returns to the Text property i set in design mode. To make it clear, i'm
happy with this behaviour, but I'd like to know why the Text property gets
resetted to the designtime value... Just in case i'm doing something real
wrong, i'm new to inheriting controls and so on...
TIA
ASC