Ask a Question related to ASP.NET General, Design and Development.
-
Kristof Pauwels #1
Problem with Eventhandlers dynamicly created MobileControls
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 fucker 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
Kristof Pauwels Guest
-
Creating columns dynamicly
Hello Everyone, While developing a little site, it comes out it would be very conveniant if I could dynamicly creaty new columns in my access... -
Updating to OS 10.2.8 created an AI 10.0.3 problem.
I just upgraded my Mac G4 (AGP Graphics) to OS 10.2.8 and I have a problem with AI 10.0.2. Everytime I start it up, I get a dialog box that states "... -
Problem with the component created in VB for ASP
Hello friends! I just created a component in VB which when a user enters username and password when clicked will validate and redirect him to a... -
name an array dynamicly??is it possible?
Hi I'm trying to give an array a name which was created dynamicly, eg: ------ arrayName = "array_1"; arrayName = new array(); ------ But i... -
problem with name created when control is rendered.
Hello, I am creating a html server control that is in a datalist. I need to access this controls value on the client via javascript but the name... -
Rahul Singh #2
Re: Problem with Eventhandlers dynamicly created MobileControls
Kristof,
Yes unless you declare that control as a protected member and then
initialize it afterwards.
I had the same problem and this seemed to solve it. You should also take a
look at how
ASP.NET generates the classes at runtime. It uses a function called
ParseControl (which takes the string representation of a control
and adds it to the Page object you're working with)
Rahul Singh
anant systems, inc. | making information work for you
anantsystems.net | ioserver.net [Developer and Business .NET Hosting]
"Kristof Pauwels" <kristof.pauwels@cyberlan.be> wrote in message
news:_uyUa.34259$F92.3791@afrodite.telenet-ops.be...device,> Hellow, I have this peace of code from an ASP.NET page for a Mobilepost,> 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> 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 fucker 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
>
>
Rahul Singh Guest



Reply With Quote

