|
 |
aspx_professional thread: emphyrio
Message #1 by "Neil Newton" <neil_n@h...> on Wed, 10 Jul 2002 23:15:43
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0176_01C22AB1.88645550
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
RE: [aspx_professional] RE: emphyrioHi,
(pardon my bad English)
You are right.
I tried some hours and the only solution seems to be call createForm
during the postback in form_load event:
so...
Sub Page_Load(....)
If Page.IsPostback then
'At this time btnSubmit doesn't exist
createForm(...)
'Here btnSubmit exists and the event fires
End if
End Sub
Alessandro Facchini
Italy
----- Original Message -----
From: Thomas Fuller
To: ASPX_Professional
Sent: Thursday, July 11, 2002 11:59 PM
Subject: [aspx_professional] RE: emphyrio
That's too funny that you sent that link, I've just been working from
that for the past hour or so but can't seem to get it to function. The
only way I get it to work is if I add the control to the form from the
page load event. If I try to dynamically add the control from a button
click onto my panel then when I click on it all the controls disappear
and nothing happens. Does anyone see what's wrong below? It renders
all the controls from a configuration stored in a datatable perfectly
(with the exception being a unique case where I get a cast error) but
when I click on the button the handler that I added doesn't fire. Any
help is greatly appreciated!
Private Sub createForm(ByVal dtFormProps As DataTable)
Try
Dim dr As DataRow
Dim lblCustom As Label
Dim tbCustom As TextBox
Dim btnSubmit As Button
For Each dr In dtFormProps.Rows
lblCustom =3D New Label()
With lblCustom
.ID =3D dr("FieldName") & "_Label"
.Text =3D dr("InputLabel")
End With
Select Case dr("InputType")
Case "textbox"
tbCustom =3D New TextBox()
With tbCustom
.MaxLength =3D dr("dbFieldMax")
.ID =3D dr("FieldName")
End With
End Select
Page.FindControl("pnlLoanTypes").Controls.Add(lblCustom)
Page.FindControl("pnlLoanTypes").Controls.Add(tbCustom)
Next
btnSubmit =3D New Button()
With (btnSubmit)
.ID =3D "btnAddItem"
.Text =3D "Add Item"
End With
Me.FindControl("pnlLoanTypes").Controls.Add(btnSubmit)
AddHandler btnSubmit.Click, AddressOf Me.btnSubmit_Click
Catch ex As Exception
Response.Write(ex.Message.ToString)
Finally
End Try
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs)
Response.write("YOU CLICKED THE BUTTON")
End Sub
-----Original Message-----
From: Neil Newton [mailto:neil_n@h...]
Sent: Thursday, July 11, 2002 7:06 PM
To: ASPX_Professional
Subject: [aspx_professional] RE: emphyrio
>Alessandro,
Thanks so much. I looked up the addhandler method on the net and
immediately found this article:
http://www.devx.com/webdev/discussions/010902/featuredDiscussion.asp
I will try this technique tomorrow!
Neil
--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to
|
|
 |