Handling Events For Dynamically Created Buttons

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nathan Sokalski

    #1

    Handling Events For Dynamically Created Buttons

    I have LinkButtons that are dynamically created in one of the PostBack
    events. They must be created in the PostBack event because one of the
    variables required to determine which ones to create comes from the event
    arguments. Because the LinkButtons are not created in the Init event, they
    will not exist when I click them to perform a postback. How do I handle the
    events for these LinkButtons? I appreciate any help you can give. Thanks.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。



  • Masudur

    #2
    Re: Handling Events For Dynamically Created Buttons

    On Feb 25, 11:38 am, "Nathan Sokalski" <njsokal...@hot mail.comwrote:
    I have LinkButtons that are dynamically created in one of the PostBack
    events. They must be created in the PostBack event because one of the
    variables required to determine which ones to create comes from the event
    arguments. Because the LinkButtons are not created in the Init event, they
    will not exist when I click them to perform a postback. How do I handle the
    events for these LinkButtons? I appreciate any help you can give. Thanks.
    --
    Nathan Sokalski
    njsokal...@hotm ail.comhttp://www.nathansokal ski.com/
    Hi...

    Once you have created the controls... constract a viewstate variable
    or session variable to that you can know that dynamically created
    links are exists...
    After each post back "on Init" first determine wheither dynamically
    added controls exists or not... if exists do create the dynamically
    added links again...
    asp.net will automatically map the event and fire it...
    but make sure the control ids remain same...


    Masudur


    Comment

    • Nathan Sokalski

      #3
      Re: Handling Events For Dynamically Created Buttons

      That would be fine if the number of dynamically created LinkButtons had a
      maximum, but it doesn't. Therefore, I would not know how many to create in
      the Init event. Also, is there any site you can give me that has a good
      example of how to do this? Thanks.
      --
      Nathan Sokalski
      njsokalski@hotm ail.com
      有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。


      "Masudur" <munnacs@gmail. comwrote in message
      news:7beb1e42-d0c4-4c4d-b600-e010e3c49089@e2 5g2000prg.googl egroups.com...
      On Feb 25, 11:38 am, "Nathan Sokalski" <njsokal...@hot mail.comwrote:
      >I have LinkButtons that are dynamically created in one of the PostBack
      >events. They must be created in the PostBack event because one of the
      >variables required to determine which ones to create comes from the event
      >arguments. Because the LinkButtons are not created in the Init event,
      >they
      >will not exist when I click them to perform a postback. How do I handle
      >the
      >events for these LinkButtons? I appreciate any help you can give. Thanks.
      >--
      >Nathan Sokalski
      >njsokal...@hot mail.comhttp://www.nathansokal ski.com/
      >
      Hi...
      >
      Once you have created the controls... constract a viewstate variable
      or session variable to that you can know that dynamically created
      links are exists...
      After each post back "on Init" first determine wheither dynamically
      added controls exists or not... if exists do create the dynamically
      added links again...
      asp.net will automatically map the event and fire it...
      but make sure the control ids remain same...
      >
      >
      Masudur

      www.shatkotha.com

      Comment

      Working...