views:

97

answers:

2

I'm looking for a reliable mechanism to generate a server side postback handler for an HTMLGenericControl such as an li element.

I have some markup that I do not wish to change and would prefer to treat this in the same fashion as a standard .Net server control.

Also, I know I can use a template based control to place some .Net controls within the markup as hidden and then trigger their click events from a client side click proxy. However, I'm really enquiring as to whether this can be done better.

A: 

Look into the ASP.NET __doPostBack function. Here is a good writeup.

You can add a click handler to your li elements (or whatever) to have them call the __doPostBack function. This is what most other server controls do, so you're using the same mechanism- the only difference would be that you are manually setting the click handler on your elements.

Dave Swersky
A: 

The problem with what you need is:
- there are no server-side control with a valid event handler so that a server-side event can be triggered.

Couple of options I can think of:

  • use PageMethods
  • call the __doPostBack()
  • call a custom javascript to do a XMLHTTP request to the server
Sunny