Problem getting list box items added through jquery in code behind

后端 未结 3 1320
暗喜
暗喜 2020-12-19 20:35

I have a asp.net list box control in which i populate items using Jquery by using some code like .. $(\"#MylistBox\").append(\"

3条回答
  •  北海茫月
    2020-12-19 20:49

    The code behind will only be aware of items that were added to the Listbox object when it was created on the server. These items will be held in ViewState and repopulated during postback.
    Therefore items created dynamically on the client won't be visible to the server side code.
    If you need to get the selected value in the server side code then you are going to need to query the Request.Form[""] value during the postback.
    If you need to retrieve all items added to a list box on the client I would suggest adding them all to a hidden field value as a delimited array of strings and again retrieving them using Request.Form[""].

提交回复
热议问题