Reputation: 2257
i have this button in grid view
<asp:Button ID="btnapp" runat="server" Text="Approved" CommandName="Approved"
CommandArgument='<%#Eval("rcno")+ "," +Eval("mobile")+ "," +Eval("email") %>'
class="btn btn-success" OnClientClick="ConfirmPopup(); return false" />
when i click on this button it open popup box , in this popup box one button. how i can access commandargument value when i click on button of popup?
if you have any other solution i can try it, i want value of grid view colums of selected button after popup open
Upvotes: 0
Views: 688
Reputation: 66
<asp:Button ID="btnapp" runat="server" Text="Approved" CommandName="Approved" CommandArgument='<%#Eval("rcno")+ "," +Eval("mobile")+ "," +Eval("email") %>' class="btn btn-success" OnClientClick="return ConfirmPopup('<%#Eval("rcno")+ "," +Eval("mobile")+ "," +Eval("email") %>');" />
It will give you an error as "The server tag is not well formed" so the solution for this is to form your button tag as below
<asp:Button ID="btnapp" runat="server" Text="Approved" CommandName="Approved" CommandArgument='<%#Eval("rcno")+ "," +Eval("mobile")+ "," +Eval("email") %>' class="btn btn-success" OnClientClick=<%# String.Format("ConfirmPopup(\"{0}\",\"{1}\",\"{2}\");return false;",Eval("rcno"),Eval("mobile"),Eval("email")) %> />
This will resolve your problem. Make sure that you have JavaScript function defined with the name "ConfirmPopup" otherwise it will simply postback the form.
Hope this helps you to solve the problem.
Upvotes: 3
Reputation: 2111
I think you're looking at it slightly wrong. You want the OnClientClick
to return true or false that way the code waits before processing further..
So you want:
<asp:button ... OnClientClick='return ConfirmPopup();' />
JavaScript:
function ConfirmPopUp() {
return Confirm("Foo");
}
But then to pass in any variables you need to really pass them in the JavaScript call:
<asp:Button ID="btnapp" runat="server" Text="Approved" CommandName="Approved" CommandArgument='<%#Eval("rcno")+ "," +Eval("mobile")+ "," +Eval("email") %>' class="btn btn-success" OnClientClick="return ConfirmPopup('bar');" />
JavaScript:
function ConfirmPopUp(myVar) {
return Confirm("Foo this? "+ myVar);
}
Upvotes: 1
Reputation: 686
Well you can pass that commandargument's value to javascript function like.
<asp:Button ID="btnapp" runat="server" Text="Approved" CommandName="Approved" CommandArgument='<%#Eval("rcno")+ "," +Eval("mobile")+ "," +Eval("email") %>' class="btn btn-success" OnClientClick="ConfirmPopup('<%#Eval("rcno")+ "," +Eval("mobile")+ "," +Eval("email") %>'); return false" />
Upvotes: 1