Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6742927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:54:02+00:00 2026-05-26T11:54:02+00:00

I have a piece of code <div class=class1> <span>testing</span> </div> I will change this

  • 0

I have a piece of code

<div class="class1">
 <span>testing</span>
</div>

I will change this into html server control.

<div class="class1" id="div1" runat="server">
 <span>testing</span>
</div>

I want to add a click event.

<div class="class1" id="div1" runat="server" onclick="Test_Click">
 <span>testing</span>
</div>

On code behind, I have that event handler.

protected void Test_Click(object sernder, EventArgs e)
{
  //code
}

But it is not working.. I tried by changing onclick to onserverclick. it is still not working..

Any other way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:54:03+00:00Added an answer on May 26, 2026 at 11:54 am

    From your post I got that you want to simple go to the server side event while clicking the Div.
    You can’t directly give this to a DIV, instead you can use a Hidden Button in the div and trigger the click event manually.

        <script>
        function clickDiv() {
        if (__doPostBack) {
            __doPostBack('<%=btnNew.UniqueID %>', '');
        }
        else {
            var theForm = document.forms['aspnetForm'];
            if (!theForm) {
                theForm = document.aspnetForm;
            }
            if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
                theForm.__EVENTTARGET.value = '<%=btnNew.UniqueID %>';
                theForm.__EVENTARGUMENT.value = '';
                theForm.submit();
            }
        }
    }
        </script>
    
    <div class="class1" id="div1" runat="server" onclick="clickDiv()">
     <span>testing</span>
    <asp:Button runat="server" Style="display: none" ID="btnNew" Text="Submit" OnClick="btnNew_Click" /> 
    </div>
    

    In _Default.aspx.cs

    public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
    
            }
    
            protected void btnNew_Click(object sender, EventArgs e)
            {
                result.Text += "hey, event handler! ";
            }
    
    
        }
    

    You can see the jQuery Implementation over here:
    JQuery UI Dialog & Asp (web forms) calling event handler

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following piece of HTML code: <div class=myclass id =class1> <ol class=list>
I have this piece of HTML: <div class=embed> <iframe width=300 height=200 frameborder=0 allowfullscreen= src=http://www.youtube.com/embed/123456></iframe>
I have this piece of code: <div class=quote-box-col14> <label for=seo class=quote-service-seo>SEO</label> <input type=checkbox name=seo
In javascript suppose you have this piece of code: <div> <script type=text/javascript>var output =
I have this piece of code in my .js.erb file: $(#register_holder).html(<%= escape_javascript(render(layouts/register)) %>); I
I have a piece of code working in knockout.js like this: <div> ... some
I have this piece of code in my cms: <ul class=subsection_tabs id=tab_group_one style=clear:none;> <?php
I have this piece of code (summarized)... AnsiString working(AnsiString format,...) { va_list argptr; AnsiString
I have a piece of code looking like this : TAxis *axis = 0;
I have this piece of code #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.