Problem with Eventhandlers dynamicly created MobileControls

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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 "...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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...
    > 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
    >
    >

    Rahul Singh Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139