-3

I have an ascx user control and want to store the value of a TextBox on the usercontrol to a hidden item on the user control. I then want to reference the hidden control in the C# code behind to do some validation.

I have this hidden item

<input type="Hidden" id="Hidden1" value="" clientidnode="Static" runat="server">

I want to set the value of this hidden item after the page loads and am trying to use this J Query script

  $(document).ready(function () {
      $("p").text("The DOM is now loaded and can be manipulated.");
      var v1 = $("#<%=TxtCaseNumber.ClientID%>")
      $('#Hidden1').val(v1);
  });

I then use the C# code behind to check the value of the Hidden1 item using

string s = Hidden1.Value; 

No value is being assigned? What am I missing here?

Perry
  • 1,277
  • 2
  • 17
  • 39

2 Answers2

2

You might want to get the actual value of the textbox

var v1 = $("#<%=TxtCaseNumber.ClientID%>").val();
COLD TOLD
  • 13,513
  • 3
  • 35
  • 52
  • I also had to correct a setting in the hidden item. I had a typo and type ClientIdNode="static when it should have been ClientIdMode="static". Once those 2 items were corrected it works. – Perry Jun 30 '16 at 11:42
0

From the info above the problem was resolved by changing a setting in the hidden item to clientnode ="static" to clientidmode="Static" and by completing my code by getting the value of the text box by adding the forgotten .val.

Perry
  • 1,277
  • 2
  • 17
  • 39
  • People would be able to determine your resolution by you upvoting and marking an answer as accepted. You may also comment on the accepted answer to note the remark about the `clientmode`. – TyCobb Jun 29 '16 at 19:02