jquery - Referencing a linkbutton within a gridview thats inside a AJAX tab -
on home page have 10 grids sit inside ajax tabs etc
one grid in particular has link button called "archive" when user clicks need show seperate div textbox user has enter reason in why wont archieve selected information, problem how can name , email of row needs archieved using jquery, want information store in hidden fields , reference hidden fields code behind etc.
i tried use asp:modalpopup extender grid placed inside ajax tab modal pop extender complains can see control link button iv decided user jquery the 2 fields name , number can me achieve this?
below 1 grid need name , email address when link button pressed
<asp:hiddenfield id="hdnuserfullname" runat="server"/> <asp:hiddenfield id="hdnuseremail" runat="server" /> <div id="maincontent_tabcontrol_body" class="ajax__tab_body" style="height: 100%; display: block;"> <div id="maincontent_tabcontrol_tb2" id="maincontent_tabcontrol_tb2" class="ajax__tab_panel"> <div> <table cellspacing="0" class="tablesorter" id="maincontent_tabcontrol_tb2_grdviewusers" style="border-collapse: collapse;"> <thead> <tr> <th scope="col"> </th> <th scope="col"> full name </th> <th scope="col"> email </th> <th scope="col"> exam taken </th> <th scope="col"> date taken </th> <th scope="col"> exam total </th> </tr> </thead> <tbody> <tr> <td> <a id="maincontent_tabcontrol_tb2_grdviewusers_edit_0" href="javascript:__dopostback('ctl00$maincontent$tabcontrol$tb2$grdviewusers$ctl02$edit','')"> archieve</a> </td> <td> <a id="maincontent_tabcontrol_tb2_grdviewusers_hyperfullname_0" href="/authentication/exampaper.aspx?uid=1"> scott atkinson</a> </td> <td> <span id="maincontent_tabcontrol_tb2_grdviewusers_lblemail_0">scott.test@hotmail.co.uk</span> </td> <td> <span id="maincontent_tabcontrol_tb2_grdviewusers_lblexamtaken_0">true</span> </td> <td> <span id="maincontent_tabcontrol_tb2_grdviewusers_lbldatetaken_0">30-06-2012</span> </td> <td> <span id="maincontent_tabcontrol_tb2_grdviewusers_lblexamtotal_0">0</span> </td> </tr> </tbody> </table> </div> </div>
this jquery far, iv put alert in there make sure hitting script , is.....
$(document).ready(function () { $('#maincontent_tabcontrol_tb2_grdviewusers_edit_0').click(function () { alert('hello'); $('#dvarchive').show(); $('#maincontent_hdnuserfullname').val() == 'value of grid view column'; $('#maincontent_hdnuseremail').val() == 'email value column'; }); });
just need referencing full name column , email column populate hidden fields values of row needs archived.....
update revised jquery
any appreciated.......
$(document).ready(function () { $('.clickme').click(function () { var tr = $(this); var username; var email; username == tr.find('.username').text(); email == tr.find('email').text(); $('#maincontent_hdnuserfullname').val() == username; $('#maincontent_hdnuseremail').val() == email; return false; }); });
iv given link button classname .clickme testing purposes aswell full name has class .username , email class .email
what need jquery method called closest()
searches through dom going element find parent matching given criteria.
in case need find grid row (tr
) clicked link placed in. extract first name, etc. row.
you had 2 more mistakes:
- for assigning value variable need use
=
opposed==
. - for assigning value control in jquery need
.val(value)
opposed.val() == value
.
in other words:
$(document).ready(function () { $('.archive-button').click(function () { var tr = $(this).closest("tr"); var username = tr.find('.username').text(); var email = tr.find('.email').text(); $('#maincontent_hdnuserfullname').val(username); $('#maincontent_hdnuseremail').val(email); return false; }); });
Comments
Post a Comment