tags:

views:

1167

answers:

5

I was trying to raise a post back event by div tag. I don't know how to do that. AL I could think of is javascript, but that is not what I want. I need to call function of a class inside a event handler.

A: 

If I'm not mistaken, is order to do postback the control need to have "runat=server". Try add a id to the div tag and also the runat.

Jack
A: 

What would trigger the postback?

If you mean by clicking on a div, then all you can do is trigger a postback event using javascript.

GoodEnough
A: 

Inside the javascript can i call server function?

alice7
Does it have to be done in a server function?
jmein
You should use the comments function, not answer your own question
Matt Briggs
A: 

You need to do this with javascript. Panel renders as a div, but it doesn't have any client initiated events for you to hook into.

You can look here http://geekswithblogs.net/mnf/archive/2005/11/04/59081.aspx (and follow the links) to see how to actually fire a postback for a control via javascript manually, although this is very kloodgy.

My guess is that if you give us some more information on what it is you want to do, we could suggest a better way to do it then programmatically cause a postback.

Matt Briggs
+1  A: 

You have to use javascript:

<div id="foo" onclick="__doPostBack('foo','')">
Clicky!
</div>

Part of the difficulty is you can't pass the event target easily. There are better ways to do what you want, but you need to elaborate on your need.

FlySwat