Disable LinkButton on AJAX Success using jQuery in ASP.Net

Last Reply 7 months ago By dharmendr

Posted 7 months ago

hello,

i have LinkButton1 inside listview - and listview bind with database. each row has categoryname categoryid

- take label value of categoryid which is inside the listview and assign it to query string - show a popup

here is the script

    <script type="text/javascript">
        $(function () {
            $('[id*=LinkButton1]').on('click', function () {
                var id = $(this).closest('div[class="list whitebg"]').find('[id*=Label12]').html();
               
             
                var oldURL = window.location.protocol + "//" + window.location.host + window.location.pathname;
                var newUrl = oldURL + "?Id=" + id;
                if (window.history != 'undefined' && window.history.pushState != 'undefined') {
                    window.history.pushState({ path: newUrl }, '', newUrl);
                    $('#myModal').modal('show');

                    $("#<%=HiddenField1.ClientID %>").val(id);
                }
                return false;
            });
        });
</script>
    <asp:HiddenField ID="HiddenField1" runat="server" />

inside popup i have linkbutton2 and on click of linkbutton i call webmethod like this

 

<script type="text/javascript">
    $(function () {
        $("[id*=LinkButton2]").bind("click", function () {
            //check query string parameter
            //assign values to webmethod
            var biddescription = $("[id*=TextBox1]").val();
            var bidamount = $("[id*=TextBox2]").val();
            var status = 'Active';
            var username = '<%=@HttpContext.Current.User.Identity.Name%>';
            var projectid = $("[id*=HiddenField1]").val();

                
             
            var noofdays = $("[id*=TextBox3]").val();

            if (Page_ClientValidate("sendproposal")) {
                $.ajax({
                    type: "POST",
                    url: "allrequest.aspx/insertbid",
                    data: "{username: '" + username + "', projectid: '" + projectid + "', biddescription: '" + biddescription + "', bidamount: '" + bidamount + "' ,   status: '" + status + "', noofdays:'" + noofdays + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",


                   
                    success: function (response) {
                        //alert(response.responseText);

                        $("[id*=TextBox1]").val("");
                        $("[id*=TextBox2]").val("");
                        $("[id*=TextBox3]").val("");
                        $('#myModal').modal('hide');
                        $('#spnCharLeft').css('display', 'none');
                        $('#spnCharLeft2').css('display', 'none');
                        $('#lblTick').text('');
                        $('#lblTick2').text('✔ Perfect');
                    },
                    error: function (response) { alert(response.responseText); },
                    failure: function (response) { alert(response.responseText); }
                });
                return false;
            }
        });
    });
</script>

what i want is on success function of webmethod i want to disable linkbutton1 which is insider listview where labelid is equal to querystring value

please advice

You are viewing reply posted by: dharmendr 7 months ago.
Posted 7 months ago
dharmendr says:
$(link).attr("disabled", "disabled");

 Replace the above line with the below.

$(link).prop("disabled", true);