Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
43
rated 0 times [  46] [ 3]  / answers: 1 / hits: 16058  / 14 Years ago, wed, january 5, 2011, 12:00:00

I need to get the value of the CommandArgument attribute of a LinkButton, in an asp:Repeater.



I have an asp:Repeater with 2 LinkButtons whose CommandArgument I set to a value:



<ItemTemplate>
<tr class=odd>
<td><%#DataBinder.Eval(Container.DataItem, batch_id)%></td>
<td><%#DataBinder.Eval(Container.DataItem, productId)%></td>
<td><%#DataBinder.Eval(Container.DataItem, serial_number)%></td>
<td><%#DataBinder.Eval(Container.DataItem, activation_card_number)%></td>
<td><%#DataBinder.Eval(Container.DataItem, transaction_amount,{0:C})%></td>
<td><%#DataBinder.Eval(Container.DataItem, response_dt, {0:M/d/yyyy HH:mm:ss})%></td>
<td style=text-align:center;><%#DataBinder.Eval(Container.DataItem, resp_process_msg)%></td>
<td style=text-align:center;><%#DataBinder.Eval(Container.DataItem, resp_response_code)%></td>
<td style=text-align:center;><asp:LinkButton ID=lnkBtnRestageAdd CommandName=Add CommandArgument='<%#Eval(activation_card_number)%>' runat=server Text=stage class=add OnClientClick=return false; /></td>
<td style=text-align:center;><asp:LinkButton ID=lnkBtnRestageMinus CommandName=Subtract CommandArgument='<%#Eval(activation_card_number)%>' runat=server Text=stage class=minus OnClientClick=return false; /></td>
</tr>
</ItemTemplate>


I have suppressed the PostBack with OnClientClick=return false; so that I can pop a jQuery dialog modal when the link buttons get clicked:



if (btnAdd != null) {
$(.add).click(function() {
$(#<%=divDialogAdd.ClientID %>).removeAttr(style);
$(#<%=divDialogAdd.ClientID %>).dialog(open);
});
}


In the modal I have 2 other asp:LinkButtons, and when the 'Yes' button is clicked I do the postback like so:



yesBtn.click(function() {
setTimeout('__doPostBack('btnAdd','')', 0); //need to add a param
});


What I need to do, is somehow grab the CommandArgument value from the LinkButton in the Repeater, so that I can pass that as a parametere or assign it to a hidden field. I have tried jQuery's attr(), but that only works when the attribute was set using that function as well. How can I get this value, or what other way can I go about this?


More From » asp.net

 Answers
3

I don't think you can get that property in javascript. Because the command argument is passed as the the argument in the doPostBack function. But i think you can change your code like this to decrease the complexity.



<asp:LinkButton ID=lnkBtnRestageAdd 
CommandName=Add
CommandArgument='<%#Eval(activation_card_number)%>'
runat=server
Text=stage
class=add
OnClientClick='<%#Eval(activation_card_number,javascript:return YourFunction({0});)%>' />


do the stuff that you want to do in the function YourFunction return true if Yes is pressed and return false


[#94364] Tuesday, January 4, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
katelynn

Total Points: 378
Total Questions: 86
Total Answers: 108

Location: Azerbaijan
Member since Fri, May 12, 2023
1 Year ago
;