I am programming in VB.NET.
I am trying to make an onClick event for a div tag. How can I make this in the code behind?
I am programming in VB.NET. I am trying to make an onClick event for
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One possible solution would be to create a Webusercontrol with a Panel(will be rendered as DIV) and an invisible Button(Display:none). Onclick of the div you could click the button per javascript which would cause an automatic Postback. In Codebehind you would catch that ButtonClick-Event and Raise a custom event(DivClicked). So you can reuse that control everywhere. Something like this:
ClickableDiv.ascx
ClickableDiv.ascx Codebehind
And for example in any page(drag&drop it to the designer):
Btw, you could also use the __doPostback-function on the DIV’s onclick event to raise a Postback.