Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Adding text to textbox server control after created

Adding text to textbox server control after created

Scheduled Pinned Locked Moved ASP.NET
sysadminhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    playout
    wrote on last edited by
    #1

    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 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" 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!

    G S 2 Replies Last reply
    0
    • P playout

      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 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" 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!

      G Offline
      G Offline
      gnjunge
      wrote on last edited by
      #2

      Did you inherit your control form System.Web.UI.Webcontrols.Textbox , or from System.Web.UI.Control? If you derive from Control you will have to implement the Render function in order to render the output.

      1 Reply Last reply
      0
      • P playout

        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 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" 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!

        S Offline
        S Offline
        S Sansanwal
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups