It doesn't look like this is possible, but is there any way to pass a javascript variable into the CommandArgument field? I'm trying to pass the facility_id variable so that the code behind can access the value.
Here is my aspx code:
<script type="text/javascript">
var facility_id = 50;
</script>
<asp:Button CssClass="btn btn-primary btn-lg" ID="submitBtn" runat="server" Text="Create EDD" CommandArgument='<% facility_id.Value %>' OnClick="submitBtn_Click" />
As you expect, the
CommandArgumentis a server-side property ofButtonserver control and you can't assign it from client-side code because it does not render corresponding HTML attribute. However, you can set up a postback from client-side with__doPostBack()function as provided below:Code behind
If you cannot use
__doPostBack()function because it is undefined on the page, then you can handlePreRenderevent of that page and provideGetPostBackEventReference()method: