Simple question; How to fire button click event?

Hi,

I am creating a simple web part that is a form with 7 textboxes and a button. I have created all the controls in CreateChildControls. That is I declare them outside and create them inside.

Private txtProjectName as TextBox

Private WithEvents btnSave as Button

Protected Overrides Sub CreateChildControls()

txtProjectName = new TextBox

txtProjectName.Colums = 20

btnSave = new Button

btnSave.Text = "Save"

AddHandler btnSave.Click, AddressOf Me.btnSave_Click

End Sub

In the RenderWebPart method I use txtProjectName.RenderControl and btnSave.RenderControl.

The form renders just fine but the btnSave_Click event doesn't seem to fire at all. Or at least I cannot set txtProjectName.Text = "Test".

This is probably a stupid question but I am kicking myself for not geting this to work.

Best regards

Pal Eilertsen



Answer this question

Simple question; How to fire button click event?

  • Simple question; How to fire button click event?