I have been struggling with this issue for a few days. Initially, I was confused and looking into using code for a postback and storing my value in a hidden field. However, upon further investigation, it appears that the solution involves simply using a "doSubmit" function when the button is pressed.
The specific value I am attempting to store should only be saved when a particular button is clicked. Since multiple users may be accessing the site concurrently, global storage is not feasible. Perhaps using a cookie could work, allowing me to access the value from my .aspx.cs file.
Here is what I currently have in default.aspx:
<asp:HiddenField id="HiddenValue" value ="" runat="server"/>
//This may need to be modified to a standard hidden input field
<input name="button1" type="button" class="btn submitter" id="button1"
value="Copy" title="Create a copy of this id" onclick="SaveId(); doSubmit(); />
function SaveId() {
$('#<%=hiddenValue.ClientID%>').val("test");
}
Where "test" represents the ID being stored.
The doSubmit function performs a document.form.submit().
Although I am new to aspx and C#, and somewhat inexperienced with JavaScript and jQuery, I can see that the test value gets stored when the doSubmit command is omitted. So, I believe I have that part correct at least. My question now is, what is the best approach to retain my value when submitting this form? Should I use a cookie or is there a more efficient method?