Is there a way to set a asp.net button's CommandArgument in javascript?

前端 未结 3 716
有刺的猬
有刺的猬 2021-01-17 23:01

I have a GridView that lists a bunch of items and one of the columns has a link that displays a modal (AjaxToolkit ModalPopupExtender). Let\'s call that link \"Show\". In t

相关标签:
3条回答
  • 2021-01-17 23:04

    Not a direct answer to your question, but another possible way of solving the problem:

    Place a HiddenField control on the page. In your code-behind, before displaying the modal popup, set the value of that control to the ID of the row that was clicked (or the row number, or some identifying value). Then in the code-behind of your Save button, you can just read the value of the HiddenField.

    0 讨论(0)
  • 2021-01-17 23:17

    If you are using Updatepanel, you need to place the Hiddenfield inside the Updatepanel. Otherwise you will not be able to get/set the value stored in hiddenfield.

    0 讨论(0)
  • 2021-01-17 23:25

    Well, after continuing the research, it looks like it cannot be done. The CommandArgument property might reside in the ViewState, but for this case, it is completely server side and cannot be changed using javascript.

    0 讨论(0)
提交回复
热议问题