Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have two buttons in gridview ,"Link and UnLink". When i click on 'Link' it should show 'UnLink' button. When we click a 'Link' button, now the button becomes' UnLink'. Then we navigate to the next page of gridview and return back to the parent page,the 'UnLink' button doesn't stay. It changes to 'Link' button. How I hold the 'Unlink' button on the page change of gridview. And My code is

What I have tried:

JavaScript
$(document).off("click", ".Link").on("click", ".Link", function (e) {         
        hiddenTicketId = $(this).attr("id");
        $(this).hide();
        $('.UnLink').hide();
        $('.Link').show();
        if (hiddenTicketId == $(this).attr("id")) {
            $($(this).closest("td").find(".Link")).hide();
            $($(this).closest("td").find(".UnLink")).show();
        }
    });  
Posted
Updated 26-May-17 3:24am
v2
Comments
F-ES Sitecore 26-May-17 10:06am    
You'll need to implement a way where you "remember" what ids have link\unlink button shown then when the page loads run through the controls and configure them such that they match what is remembered. You can store this info in cookies, in local storage, in a hidden form field that is submitted with the page. You can do the remembering on the client and the setting up in client code too or the setting up on server code. There are lots of ways to implement this and all have pros and cons and the right solution depends on what your overall requirements are.

Simplest thing is probably to use the hidden field, so stick a hidden field in your form and write code that adds\removed ids to the field data as you click the various buttons then go from there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900