K
Kristof Pauwels
Hellow, I have this peace of code from an ASP.NET page for a Mobile device,
but i have a small problem.
In this first SUB I dynmamicly create a MobileControls.Command.
I add an EventHandler to this Control
But when I click on this button, the only thing I notice is there is a post,
but the eventhandler is never fired. :-(
Is it possible that a dynmicly created control looses his event after an
PostBack??
If so, or if you know where my problem is, I would be gratefull.
Thanks in advance.
Private Sub PupulateFormWithLinks(ByVal CurrentFormIndex As Integer)
Dim DataRow As DataRow
For Each DataRow In TabsDataTable.Rows
Dim TabIndex As Integer = DataRow.Item("TabIndex")
'No linkbutton on the page that reffers to itself
If TabIndex <> CurrentFormIndex Then
Dim CMDLink As New MobileControls.Command
CMDLink.Text = "-" & TabIndex & "-"
CMDLink.CommandName = "CMDLink_OnClick"
CMDLink.CommandArgument = TabIndex
CMDLink.BreakAfter = False
CMDLink.ID = "CMDLink" & TabIndex
AddHandler CMDLink.Click, AddressOf OnClick
Form1.Controls.Add(CMDLink)
End If
Next
Form1.DataBind()
End Sub
'EventHandler for the clicks on the CommandControl, but this ****er is
never fired ;-(
Sub OnClick(ByVal sender As Object, ByVal e As System.EventArgs)
Dim CurrentFormIndex As Integer = Convert.ToInt16(CType(sender,
MobileControls.Command).CommandArgument)
Form1.Controls.Clear()
PopulateFormWithFields(Accountno, 1, CurrentFormIndex
PupulateFormWithLinks(CurrentFormIndex)
ActiveForm = Form1
End Sub
but i have a small problem.
In this first SUB I dynmamicly create a MobileControls.Command.
I add an EventHandler to this Control
But when I click on this button, the only thing I notice is there is a post,
but the eventhandler is never fired. :-(
Is it possible that a dynmicly created control looses his event after an
PostBack??
If so, or if you know where my problem is, I would be gratefull.
Thanks in advance.
Private Sub PupulateFormWithLinks(ByVal CurrentFormIndex As Integer)
Dim DataRow As DataRow
For Each DataRow In TabsDataTable.Rows
Dim TabIndex As Integer = DataRow.Item("TabIndex")
'No linkbutton on the page that reffers to itself
If TabIndex <> CurrentFormIndex Then
Dim CMDLink As New MobileControls.Command
CMDLink.Text = "-" & TabIndex & "-"
CMDLink.CommandName = "CMDLink_OnClick"
CMDLink.CommandArgument = TabIndex
CMDLink.BreakAfter = False
CMDLink.ID = "CMDLink" & TabIndex
AddHandler CMDLink.Click, AddressOf OnClick
Form1.Controls.Add(CMDLink)
End If
Next
Form1.DataBind()
End Sub
'EventHandler for the clicks on the CommandControl, but this ****er is
never fired ;-(
Sub OnClick(ByVal sender As Object, ByVal e As System.EventArgs)
Dim CurrentFormIndex As Integer = Convert.ToInt16(CType(sender,
MobileControls.Command).CommandArgument)
Form1.Controls.Clear()
PopulateFormWithFields(Accountno, 1, CurrentFormIndex
PupulateFormWithLinks(CurrentFormIndex)
ActiveForm = Form1
End Sub