Adding text to textbox server control after created
-
Hi everyone, I need to be able to change the textbox.text property once the textbox has been created. I create my textbox dynamically (server control). Here is my code: TextBox class
Public _Text As String Public _ID As String Public _Wrap As Boolean Public _Rows As Integer Public _Columns As Integer Public _TextMode As TextBoxMode = TextBoxMode.MultiLine Public Overridable Property SetText() As String Get Return _Text End Get Set(ByVal Value As String) _Text = Value End Set End Property Public Property SetWrap() As Boolean Get Return _Wrap End Get Set(ByVal Value As Boolean) _Wrap = Value End Set End Property Public Property SetRows() As Integer Get Return _Rows End Get Set(ByVal Value As Integer) _Rows = Value End Set End Property Public Property SetColumns() As Integer Get Return _Columns End Get Set(ByVal Value As Integer) _Columns = Value End Set End Property Public Property SetID() As String Get Return _ID End Get Set(ByVal Value As String) _ID = Value End Set End Property Public Sub Control_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init Dim TextBox1 As New TextBox TextBox1.ID = SetID() TextBox1.Wrap = SetWrap() TextBox1.Rows = SetRows() TextBox1.Columns = SetColumns() TextBox1.Text = SetText() TextBox1.TextMode = TextBoxMode.MultiLine Controls.Add(TextBox1) End Sub
ControlLoad classDim objFormControl As New FormControl.MultiText 'FormControl = project name (DLL) 'MultiText = class FormControl._Wrap = True FormControl._ID = "txtTest" FormControl._Rows = 3 FormControl._Columns = 25 Me.controls.add(FormControl) FormControl._Text = "Textbox Text Change"
When I add the text to the textbox after it has been created, it does not show the text in the browser. :confused: Can someone help me! -
Hi everyone, I need to be able to change the textbox.text property once the textbox has been created. I create my textbox dynamically (server control). Here is my code: TextBox class
Public _Text As String Public _ID As String Public _Wrap As Boolean Public _Rows As Integer Public _Columns As Integer Public _TextMode As TextBoxMode = TextBoxMode.MultiLine Public Overridable Property SetText() As String Get Return _Text End Get Set(ByVal Value As String) _Text = Value End Set End Property Public Property SetWrap() As Boolean Get Return _Wrap End Get Set(ByVal Value As Boolean) _Wrap = Value End Set End Property Public Property SetRows() As Integer Get Return _Rows End Get Set(ByVal Value As Integer) _Rows = Value End Set End Property Public Property SetColumns() As Integer Get Return _Columns End Get Set(ByVal Value As Integer) _Columns = Value End Set End Property Public Property SetID() As String Get Return _ID End Get Set(ByVal Value As String) _ID = Value End Set End Property Public Sub Control_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init Dim TextBox1 As New TextBox TextBox1.ID = SetID() TextBox1.Wrap = SetWrap() TextBox1.Rows = SetRows() TextBox1.Columns = SetColumns() TextBox1.Text = SetText() TextBox1.TextMode = TextBoxMode.MultiLine Controls.Add(TextBox1) End Sub
ControlLoad classDim objFormControl As New FormControl.MultiText 'FormControl = project name (DLL) 'MultiText = class FormControl._Wrap = True FormControl._ID = "txtTest" FormControl._Rows = 3 FormControl._Columns = 25 Me.controls.add(FormControl) FormControl._Text = "Textbox Text Change"
When I add the text to the textbox after it has been created, it does not show the text in the browser. :confused: Can someone help me! -
Hi everyone, I need to be able to change the textbox.text property once the textbox has been created. I create my textbox dynamically (server control). Here is my code: TextBox class
Public _Text As String Public _ID As String Public _Wrap As Boolean Public _Rows As Integer Public _Columns As Integer Public _TextMode As TextBoxMode = TextBoxMode.MultiLine Public Overridable Property SetText() As String Get Return _Text End Get Set(ByVal Value As String) _Text = Value End Set End Property Public Property SetWrap() As Boolean Get Return _Wrap End Get Set(ByVal Value As Boolean) _Wrap = Value End Set End Property Public Property SetRows() As Integer Get Return _Rows End Get Set(ByVal Value As Integer) _Rows = Value End Set End Property Public Property SetColumns() As Integer Get Return _Columns End Get Set(ByVal Value As Integer) _Columns = Value End Set End Property Public Property SetID() As String Get Return _ID End Get Set(ByVal Value As String) _ID = Value End Set End Property Public Sub Control_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init Dim TextBox1 As New TextBox TextBox1.ID = SetID() TextBox1.Wrap = SetWrap() TextBox1.Rows = SetRows() TextBox1.Columns = SetColumns() TextBox1.Text = SetText() TextBox1.TextMode = TextBoxMode.MultiLine Controls.Add(TextBox1) End Sub
ControlLoad classDim objFormControl As New FormControl.MultiText 'FormControl = project name (DLL) 'MultiText = class FormControl._Wrap = True FormControl._ID = "txtTest" FormControl._Rows = 3 FormControl._Columns = 25 Me.controls.add(FormControl) FormControl._Text = "Textbox Text Change"
When I add the text to the textbox after it has been created, it does not show the text in the browser. :confused: Can someone help me!You are assigning value to _Text property and not to Text property of TextBox created. The best way is to have the textbox control declared outside the control_load function. TextBox class private TextBox1 As New TextBox Public _Text As String Public _ID As String Public _Wrap As Boolean Public _Rows As Integer Public _Columns As Integer Public _TextMode As TextBoxMode = TextBoxMode.MultiLine Public Overridable Property SetText() As String Get Return _Text End Get Set(ByVal Value As String) _Text = Value TextBox1.Text = value ‘ DO this for all properties End Set End Property Public Property SetWrap() As Boolean Get Return _Wrap End Get Set(ByVal Value As Boolean) _Wrap = Value End Set End Property Public Property SetRows() As Integer Get Return _Rows End Get Set(ByVal Value As Integer) _Rows = Value End Set End Property Public Property SetColumns() As Integer Get Return _Columns End Get Set(ByVal Value As Integer) _Columns = Value End Set End Property Public Property SetID() As String Get Return _ID End Get Set(ByVal Value As String) _ID = Value End Set End Property Public Sub Control_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init TextBox1.ID = SetID() TextBox1.Wrap = SetWrap() TextBox1.Rows = SetRows() TextBox1.Columns = SetColumns() TextBox1.Text = SetText() TextBox1.TextMode = TextBoxMode.MultiLine Controls.Add(TextBox1) End Sub ControlLoad class Dim objFormControl As New FormControl.MultiText 'FormControl = project name (DLL) 'MultiText = class FormControl._Wrap = True FormControl._ID = "txtTest" FormControl._Rows = 3 FormControl._Columns = 25 Me.controls.add(FormControl) FormControl._Text = "Textbox Text Change" Note: The best way is to inherit to your textbox calss from WeControl TextBox itslef, then you would have all default properties plus you could overide any property Sanjay Sansanwal www.sansanwal.com