selecting value via dynamicaly created list of buttons

  • Thread starter Achim Domma (Procoders)
  • Start date
A

Achim Domma (Procoders)

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
 
J

Johannes Hammersen

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
 
A

Achim Domma (Procoders)

Johannes said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top