selecting value via dynamicaly created list of buttons

Discussion in 'ASP .Net' started by Achim Domma (Procoders), Jun 29, 2005.

  1. Hi,

    to allow my user to select from a list of values which are calculated on
    the fly, I tried to generate a list of LinkButton controls on the fly.
    But the connected event does not fire.

    Searching google I found out that the problem is caused by the structure
    of the ASP.Net event handling: The clicked button does not exist anymore
    after the postback, so no event could be fired.

    Does anybody know a simple workaround?

    My requirements are quite simple:

    I want to write a control which display a list of options. In classic
    ASP I would do something like (for example generated out of a database):

    <a href='page.asp?selection=aaa'>aaa</a><br>
    <a href='page.asp?selection=bbb'>bbb</a><br>
    <a href='page.asp?selection=ccc'>ccc</a><br>
    <a href='page.asp?selection=ddd'>ddd</a><br>
    ....

    And in the page:

    var selection = Request("selection");

    How can I do something like this in ASP.Net?

    regards,
    Achim
     
    Achim Domma (Procoders), Jun 29, 2005
    #1
    1. Advertising

  2. Hi Achim,

    > Does anybody know a simple workaround?


    one way to do it, is to recreate the exact same page you send to the client
    again. That way the events can fire.
    Afterwards you can call yourself again to load a new page for the client.
    What you will need to do, is create a boolean in your session to tell
    yourself if this time you are calling yourself, or the client is calling you
    so you know if you should restore the last page, and react to the events.


    > My requirements are quite simple:
    >
    > I want to write a control which display a list of options. In classic ASP
    > I would do something like (for example generated out of a database):
    >
    > <a href='page.asp?selection=aaa'>aaa</a><br>
    > <a href='page.asp?selection=bbb'>bbb</a><br>
    > <a href='page.asp?selection=ccc'>ccc</a><br>
    > <a href='page.asp?selection=ddd'>ddd</a><br>
    > ...


    Of course you can also just do it the good old asp way, and actualy create
    those Hyperlinks to youself and then check Request.QueryString if any of
    them were used.


    Hope this helps
    Johannes
     
    Johannes Hammersen, Jun 29, 2005
    #2
    1. Advertising

  3. Johannes Hammersen wrote:

    > one way to do it, is to recreate the exact same page you send to the client
    > again. That way the events can fire.
    > Afterwards you can call yourself again to load a new page for the client.
    > What you will need to do, is create a boolean in your session to tell
    > yourself if this time you are calling yourself, or the client is calling you
    > so you know if you should restore the last page, and react to the events.


    That's no option. The date required to rebuild the page would be to
    expensive to calculated and I don't want to store it.

    > Of course you can also just do it the good old asp way, and actualy create
    > those Hyperlinks to youself and then check Request.QueryString if any of
    > them were used.


    The control will be part of a SharePoint Webpart and I don't know how
    this solution would interact with SharePoint.

    If found another solution: I generate the links as <a href> Tag, using
    GetPostBackClientHyperlink to generate the href. The creating control
    handles the postback and generates the appropriate event.

    regards,
    Achim
     
    Achim Domma (Procoders), Jun 29, 2005
    #3
    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. Bisser Milanov
    Replies:
    2
    Views:
    531
    Bisser Milanov
    Jun 26, 2003
  2. Carlos Cruz

    Events of a dynamicaly created control

    Carlos Cruz, May 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    315
    Rick Spiewak
    May 2, 2004
  3. Totto
    Replies:
    6
    Views:
    2,264
    Totto
    Aug 22, 2006
  4. smcglynn

    Selecting <buttons> via VB

    smcglynn, Jun 28, 2011, in forum: HTML and CSS
    Replies:
    0
    Views:
    358
    smcglynn
    Jun 28, 2011
  5. Dr. Leff
    Replies:
    3
    Views:
    301
    David Mark
    Oct 15, 2007
Loading...

Share This Page