How to write a server events for 'Document' object of a ASP.NET page?

A

ABC

If there have a page which have unknown '<div>' label or may be no any
controls. I want add 'onclick' events to call server event to do something.
But there are no any events of 'Document' object on properties windows under
VS IDE. How should I to do?
 
L

Lau Lei Cheong

<div id="div_1" onclick="div_clicked();"> <input type="hidden"
id="hid_clickedctlname" runat="server">

include a javascript block...
<script language="javascript">
function div_clicked() {
document.getElementById("hid_clickedctlname").value = "div_1";
form.submit();
}
</script>

Now on the codebehind, you can check this.IsPostBack and the
hid_clickedctlname.Value to see if the div is clicked...
 

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

Top