javascript - Using Val() to set the value of a hidden field in ASP.NET web form -


I am trying to use val () to change the values ​​of hidden fields in asp.net. I am new to both asp and jquery so please bare with me.

My jquery is as follows:

  $ ("# blue"). Val ("green");   

ASP:

  & lt; ASP: Hildfield id = "blue" runat = "server" client idmode = "static" />   

I'm looking for results:

  & lt; Asp: HiddenField id = "blue" runat = "server" value = "green" clientidmode = "static" />   

Output of the following in HTML:

  & lt; Input type = "hidden" value = "green" id = "blue" />   

What's happening to me:

  & lt; Input type = "hidden" id = "blue" />   

I can find $ ("# blue"). Text ("green"); No problem, thanks for any suggestions.

Because of this, I want to change the values ​​because I am pulling value from various JS files.

Sorry but I can not understand one thing: when will you have to change that value? ???

In the example, assume that you load a page and then decide to click a button in this case you can change the hidden value with the jquery statement or even if You want and if you have a full postback, you can change the button_click event (when it is removed) in the value of the hidden file .... can you give more information ????

For this moment, I can help you with some lines of code:

ASP page:

   & Lt; Asp: button runat = "server" id = "btnDoSomething" text = "change hidden field value" / & gt; Possible solutions via JS with little modification for ASP: Button:  
  & asp: hiddenfield runat = "server" id = "blue" ClientIDMode = "static" /> & Lt; Asp: button runat = "server" id = "btnDoSomething" text = "Change hidden field value" onclientClick = "UpdateHiddenField ();" /> & Lt; Script & gt; Function UpdateHiddenField () {$ ("# blue"). Val ("green"); return false; } & Lt; / Script & gt;   

I checked and it works fine.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -