Linkbutton Click event handler not executing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Assaf Weinberg

    #1

    Linkbutton Click event handler not executing

    Using ASP.NET web form with VB.NET

    I have a page with a calendar control that
    onSelectionChan ged builds a table control showing the
    events scheduled for the selected calendar days. One of
    the columns in this table contains linkbuttons that, when
    clicked, should execute some code (currently an event
    handler called showEvent) that displays details.

    I am currently using addhandler to specify the handler for
    the linkbutton click events. When clicked, the
    linkbuttons cause a postback, but mysteriously do not
    execute the showEvent function.

    Here is the code that creates the linkbuttons - it gets
    called by the onSelectionChan ged of the calendar:

    For Each row In editor.dataTabl e.Rows

    Dim tablerow As New TableRow()
    Dim dateCell As New TableCell()
    Dim titleCell As New TableCell()
    Dim officeCell As New TableCell()
    Dim link As New LinkButton()
    ...

    'Set linkbutton attributes
    link.Attributes ("class") = "noDecor"
    link.Text = row("eventTitle ")
    link.ID = "lnk" + CStr(row("event ID"))

    'Add click handler
    AddHandler link.Click, AddressOf showEvent

    'Add all elements to the new tablerow and add
    it to the output table
    titleCell.Contr ols.Add(link)
    ...

    Next

    Let me know if you have any ideas

  • Marina

    #2
    Re: Linkbutton Click event handler not executing

    Dynamic controls need to be recreated on postback for their event handlers
    to run.

    "Assaf Weinberg" <aweinberg@kies ling.com> wrote in message
    news:01ae01c35c 47$fd488e90$a40 1280a@phx.gbl.. .[color=blue]
    > Using ASP.NET web form with VB.NET
    >
    > I have a page with a calendar control that
    > onSelectionChan ged builds a table control showing the
    > events scheduled for the selected calendar days. One of
    > the columns in this table contains linkbuttons that, when
    > clicked, should execute some code (currently an event
    > handler called showEvent) that displays details.
    >
    > I am currently using addhandler to specify the handler for
    > the linkbutton click events. When clicked, the
    > linkbuttons cause a postback, but mysteriously do not
    > execute the showEvent function.
    >
    > Here is the code that creates the linkbuttons - it gets
    > called by the onSelectionChan ged of the calendar:
    >
    > For Each row In editor.dataTabl e.Rows
    >
    > Dim tablerow As New TableRow()
    > Dim dateCell As New TableCell()
    > Dim titleCell As New TableCell()
    > Dim officeCell As New TableCell()
    > Dim link As New LinkButton()
    > ...
    >
    > 'Set linkbutton attributes
    > link.Attributes ("class") = "noDecor"
    > link.Text = row("eventTitle ")
    > link.ID = "lnk" + CStr(row("event ID"))
    >
    > 'Add click handler
    > AddHandler link.Click, AddressOf showEvent
    >
    > 'Add all elements to the new tablerow and add
    > it to the output table
    > titleCell.Contr ols.Add(link)
    > ...
    >
    > Next
    >
    > Let me know if you have any ideas
    >[/color]


    Comment

    Working...