þÍńķ
þÍńķ

Reputation: 363

Disable onclick which is in table by Jquery?

I'm using Jquery in asp.net

I'm using a User control which will bind DropDown list of values from DataBase dynamically.

But when it is in edit mode i just want to disable this user control which is not direct child to my page. (it is child's child)

<div id="divPTSearchItems" runat="server" class="dropdown">
<asp:DataList ID="dlPTSearchItems" RepeatDirection="Vertical" HorizontalAlign="Left" runat="server">
    <ItemTemplate>
        <table class="dlitem" height="25px" width="100%"  **onclick="PTSetsearchtext(this)**;">
            <tr>
                <td>
                    <asp:Label ID="lblPTText" value='<%#Eval("PTValue") %>' runat="server" CssClass="dropdownlabel" Text='<%#Eval("PTText") %>'></asp:Label>
                </td>
            </tr>
        </table>
    </ItemTemplate>
    <ItemStyle Height="25px" Width="100%" CssClass="dlitem" />
</asp:DataList>

When i try to disable the div it is getting disabled but the Dropdown click is working, it must totally hide the div without the click event also working. I just wanted to disable the click event of the table in my parent page.

Any help is thankful

Upvotes: 1

Views: 407

Answers (1)

Denys Wessels
Denys Wessels

Reputation: 17039

If I understand the question correctly you want to disable all the controls inside a specific div, if that's correct try this jQuery function:

disableDivById = function(divId, disable) {
    divId = "#" + divId
    $(divId).prop('disabled', disable);
}

and call it to disable a particular div like this:

disableDivById("divPTSearchItems", true);

Upvotes: 1

Related Questions