Dynamic Link Buttons

Discussion in 'ASP .Net' started by brian, Jun 9, 2004.

  1. brian

    brian Guest

    This is the first time I have tried to create dynamic
    controls. I am trying to create a hyperlink control.
    The control will display properly but the event isn't
    triggered.

    I read a lot of stuff pertaining to this topic but have
    not been able to figure out my problem. TEST() is
    processed when I click a command button which creates the
    dynamci link buttons. The dynamic link buttons display
    fine but have no event when clicked.

    Can someone please give a few suggestions.

    Thanks

    Private sub TEST()
    'All variables have been declared. Left them out to save
    'Room
    l.Text = JobParsed
    l.ID = 1
    l.CommandName = "Link"
    LinkControl.Controls.Add(l)
    AddHandler l.Click, AddressOf l_Click
    Next
    End Sub

    Public Sub l_Click(ByVal Sender As Object, ByVal E As
    System.EventArgs)
    Response.Write("Button Clicked")
    End Sub
     
    brian, Jun 9, 2004
    #1
    1. Advertising

  2. brian

    bruce barker Guest

    I assume you are creating the controls on a button click. when the postback
    from the hyperlink happens you need to recreate the controls (say in form
    load) and reassign the handlers. you can save a flag to do this in viewstate
    or a hidden field.

    -- bruce (sqlwork.com)


    "brian" <> wrote in message
    news:1a6b301c44e6c$d31798b0$...
    > This is the first time I have tried to create dynamic
    > controls. I am trying to create a hyperlink control.
    > The control will display properly but the event isn't
    > triggered.
    >
    > I read a lot of stuff pertaining to this topic but have
    > not been able to figure out my problem. TEST() is
    > processed when I click a command button which creates the
    > dynamci link buttons. The dynamic link buttons display
    > fine but have no event when clicked.
    >
    > Can someone please give a few suggestions.
    >
    > Thanks
    >
    > Private sub TEST()
    > 'All variables have been declared. Left them out to save
    > 'Room
    > l.Text = JobParsed
    > l.ID = 1
    > l.CommandName = "Link"
    > LinkControl.Controls.Add(l)
    > AddHandler l.Click, AddressOf l_Click
    > Next
    > End Sub
    >
    > Public Sub l_Click(ByVal Sender As Object, ByVal E As
    > System.EventArgs)
    > Response.Write("Button Clicked")
    > End Sub
     
    bruce barker, Jun 10, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RSB
    Replies:
    0
    Views:
    756
  2. brian

    Dynamic Link Buttons

    brian, Jun 14, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    423
    =?Utf-8?B?S2FtYWwgVC4=?=
    Jun 14, 2004
  3. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    893
    Kevin Spencer
    May 17, 2005
  4. Roger
    Replies:
    1
    Views:
    649
    GreggTB
    May 20, 2005
  5. =?Utf-8?B?QmVu?=

    Image Buttons/Buttons not responding

    =?Utf-8?B?QmVu?=, Jul 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    461
    Teemu Keiski
    Jul 6, 2005
Loading...

Share This Page