12

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 that modal, I have a asp:button for saving the data entered in that modal. Let's call that button "Save"

So when the user clicks on a "Show" link in a certain row, I'd like write some javascript that sets something in the "Save" button, so that in my code-behind, I can handle "Save".Command and use the CommandEventArgs parameter to get the value.

Is this possible, or do I just need to use a hidden input tag and set its value?

asked Feb 26, 2009 at 23:59

3 Answers 3

23

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.

answered Feb 27, 2009 at 0:17

Comments

14

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.

answered Feb 27, 2009 at 0:24

Comments

1

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.

answered Feb 4, 2016 at 4:04

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.