Ajax RRS feed

  • Question

  • User491718545 posted


    How to  take selected cell header text and  table row id using ajax..

    i have one table when i drag table cell table cell color wil be orange..that particular selected cell header text and row id want to get??


    id    Name          01  02

    1      sankar        p     a      when i select cell p,a want to get headertext and id--my result will be  1 01,1 02

    2       Naveen      p     p

    give me solution for that above question pl??


    Tuesday, October 22, 2013 12:25 AM


  • User-417640953 posted

    Hi ShriNaveen,

    I'm glad to you post the issue to asp.net forum.

    From your description, I see that you want to select the text of table cells. Set the background of selected cells as "orange" and get the cell's header or position.

    If you want to change the html element text selection default color. Please use property unselectable and onselectstart.

    Below is a simple demo for it.

     <script src="../../Scripts/jquery-1.7.1.js"></script>
            //set globe a flag 
            var flag = false;
            $(function () {
                $(document).mousedown(function (event) {
                    $("#MyTable").find("td").css("background-color", "white");
                $(document).mouseup(function () {
                    flag = false;
                $("#MyTable").find("td").mousedown(function () {
                    flag = true;
                $("#MyTable").find("td").mouseup(function () {
                    flag = false;
                $("#MyTable").find("td").mousemove(function () {
                    if (flag) {  
                        $(this).css("background-color", "orange");
                //you can get the text, position of selected cells by the class "selectedCell"
                //your code.....
    <body unselectable='on' onselectstart='return false;'>
        <form id="form1" runat="server" >
        <table id="MyTable" border="1" >
            <tr >
                <td >1</td>

    In above code, you can get the selected cells by it class 'selectedCell'. Then you can get it's header or id easily.




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 24, 2013 4:42 AM