Jump to content
Xtreme .Net Talk

Recommended Posts

Posted


   Sub ShowMyTextBox()
       Dim MyTextBox As New TextBox
       MyTextBox.ID = "MyTextBox" 
       MyTextBox.Text = "MyTextBox"
       Me.Panel1.Controls.Add(MyTextBox)

   End Sub

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       ShowMyTextBox()
   End Sub

 

As pasted above, I have two button in a web form.

Button1 is to create a textbox.

I have the other button named Button2.

When I press Button2, the created text box is disappear.

Can you tell me why the created textbox is disappear when I press button2??

George C.K. Low

Posted

YeH...

thanks a lot.. I think I had figured out a way to do so..

 

First, I declare a global flag variable in my main aspx.

 

When I create ShowMyTextBox(), I will set the flag to true.

 

so, everytime I post back the page, I will read the global variable. If it is not false, I will call ShowMyTextBox()

George C.K. Low

Posted

ok, a way to make the value remained.

 

Dim txt1 as new TextBox

Private Sub Load(....)
    if txt1.text <> "" then
         me.controls.add(txt1)
    end if
End Sub

Private Sub Button1_Click(.....) Handles Button1.Click
    txt1.text = "Hello"
    me.controls.add(txt1)
End Sub

 

Got my idea???

George C.K. Low

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...