Problem getting list items added via jquery to code behind

I have an asp.net list control in which I populate the elements using jquery using some code, for example .. $("#MylistBox").append("<option value='somevalue'>Someitem</option>

dynamically. but in the code, when I use it MylistBox.Itemsalways shows Count 0no matter how many elements are added.

Can anyone help me with this?

+3
source share
2 answers

Without knowing the actual scenario ... I assume that your goal is to get dynamically added elements either by iterating over them, or something else ...

DOM, JavaScript/jQuery, . - . - Select . runat = server, , Request.Form [ "... NAME ... NOT ID..." ], . , , , , .

, , : "1: , 2: , 3:...". , .

+5

, Listbox, . ViewState .
, , .
, Request.Form["<Listbox client id>"] .
, , Request.Form["<hidden field id>"].

+1

Source: https://habr.com/ru/post/1788927/


All Articles