Click here to Skip to main content
16,005,080 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: ASP setup Pin
patty3-May-02 7:39
patty3-May-02 7:39 
GeneralRe: ASP setup Pin
Nick Parker5-May-02 16:55
protectorNick Parker5-May-02 16:55 
GeneralRe: ASP setup Pin
patty6-May-02 0:12
patty6-May-02 0:12 
GeneralHelp me! Pin
t800t83-May-02 1:20
t800t83-May-02 1:20 
GeneralRe: Help me! Pin
Fernando Finelli3-May-02 4:49
Fernando Finelli3-May-02 4:49 
GeneralRe: Help me! Pin
3-May-02 4:57
suss3-May-02 4:57 
GeneralThis is my code. Pin
t800t83-May-02 17:58
t800t83-May-02 17:58 
QuestionPossible Bug? Pin
Jamie Nordmeyer2-May-02 12:23
Jamie Nordmeyer2-May-02 12:23 
We have the following test class
Public Class MyTextBox : Inherits TextBox
End Class

It's empty on purpose. Now, the class is used as follows in a web page:
Public Class WebForm1 : Inherits System.Web.UI.Page
   Private mTextBox As TextBox
   Private mButton As Button

   Public ReadOnly Property Form() As HtmlForm
      Get
         Return CType(Me.FindControl("Form1"), HtmlForm)
      End Get
   End Property

   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Me.EnableViewState = True
      mTextBox = New TextBox()
      Me.Form.Controls.Add(mTextBox)
      mButton = New Button()
      Me.Form.Controls.Add(mButton)
      AddHandler mButton.Click, AddressOf Me.ButtonClick
      If Not Me.IsPostBack Then
         mTextBox.Text = "ABCDEF"
         mButton.Text = "PressMe"
      End If
      Debug.WriteLine("PostBack=" & Me.IsPostBack)
      Debug.WriteLine("Text=" & mTextBox.Text)
      Debug.WriteLine("Button=" & mButton.Text)
   End Sub

   Private Sub ButtonClick(ByVal Sender As Object, ByVal E As EventArgs)
      Debug.WriteLine("ButtonClick")
      Debug.Indent()
      Debug.WriteLine("Text=" & mTextBox.Text)
      Debug.WriteLine("Button=" & mButton.Text)
      Debug.Unindent()
      Debug.WriteLine("ButtonClick")
   End Sub
End Class

The output after loading the page, and clicking the button looks as follows:
PostBack=False
Text=ABCDEF
Button=PressMe
PostBack=True
Text=
Button=PressMe
ButtonClick
    Text=ABCDEF
    Button=PressMe
ButtonClick

Now, if I change the mTextBox variable to be a MyTextBox, and say mTextBox = New MyTextBox, I get the following:
PostBack=False
Text=ABCDEF
Button=PressMe
PostBack=True
Text=ABCDEF
Button=PressMe
ButtonClick
    Text=ABCDEF
    Button=PressMe
ButtonClick

The difference is that on the first trial (when mTextBox is a TextBox), Text is Nothing before the button click, but correct afterward. When mTextBox is a MyTextBox, Text is already set. Huh? WTF | :WTF: Isn't anything declared as a MyTextBox simply a TextBox, since there's no additional implementation?

Jamie Nordmeyer
Portland, Oregon, USA
QuestionUploading writing text to a file? Pin
Rickard Andersson202-May-02 3:09
Rickard Andersson202-May-02 3:09 
AnswerRe: Uploading writing text to a file? Pin
Not Active2-May-02 7:12
mentorNot Active2-May-02 7:12 
GeneralRe: Uploading writing text to a file? Pin
Rickard Andersson202-May-02 20:37
Rickard Andersson202-May-02 20:37 
GeneralRe: Uploading writing text to a file? Pin
Not Active3-May-02 3:58
mentorNot Active3-May-02 3:58 
GeneralASP.NET and image maps Pin
Not Active1-May-02 14:23
mentorNot Active1-May-02 14:23 
GeneralRe: ASP.NET and image maps Pin
Philip Patrick2-May-02 10:15
professionalPhilip Patrick2-May-02 10:15 
GeneralRe: ASP.NET and image maps Pin
Not Active2-May-02 18:08
mentorNot Active2-May-02 18:08 
GeneralHelp Required with ADO on ASP Pin
simonjackson@att.net1-May-02 9:43
simonjackson@att.net1-May-02 9:43 
GeneralRe: Help Required with ADO on ASP Pin
Nick Parker1-May-02 10:48
protectorNick Parker1-May-02 10:48 
GeneralRe: Help Required with ADO on ASP Pin
Philip Patrick1-May-02 22:52
professionalPhilip Patrick1-May-02 22:52 
GeneralIP Address Pin
Statbat30-Apr-02 7:31
Statbat30-Apr-02 7:31 
GeneralRe: IP Address Pin
Jason Jystad30-Apr-02 12:01
Jason Jystad30-Apr-02 12:01 
GeneralRe: IP Address Pin
Fernando Finelli3-May-02 4:51
Fernando Finelli3-May-02 4:51 
GeneralLoadControl Pin
Jamie Nordmeyer30-Apr-02 7:00
Jamie Nordmeyer30-Apr-02 7:00 
GeneralRegular Expression messing about Pin
Chris Maunder29-Apr-02 21:12
cofounderChris Maunder29-Apr-02 21:12 
GeneralRe: Regular Expression messing about Pin
Andrew Peace30-Apr-02 1:38
Andrew Peace30-Apr-02 1:38 
GeneralRe: Regular Expression messing about Pin
Chris Maunder30-Apr-02 1:47
cofounderChris Maunder30-Apr-02 1:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.