I am implenting some functionality on asp.net page such that: There are to listboxes side by side, left one is prepopulated and right one is empty. Besides left listbox there is add button and besides right there is remove button. I have written javascript code such that on Add button click the selected listItems from left listbox are moved to right listbox and vice-versa.
It is as follows:
When I submit the form, in code-behind I am not able to retrive the newly moved values from right ListBox (I know its not posssible in this way). How can I access the changes made with the javascript changes to the listboxes in the codebehind .
Any help appreciated.
I think while you are loading the page contents inside Page_Load(),make sure that you are loading after checking whether is a post back request or not.Load the events if it is not a postback request.
ie :-
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
//load the contents of the page/listbox here.
}
}
<form id="form1" runat="server">
<div>
<select id="greet" name="greet" multiple="multiple">
<option>Mr</option>
<option>Mrs</option>
<option>Miss</option>
<option>Dr</option>
</select>
<asp:Button Text="Submit" runat="server" ID="btnSubmit"
OnClick="btnSubmit_Click" />
</div>
</form>
protected void btnSubmit_Click(object sender, EventArgs e)
{
string greets = Request["greet"];
}
I was able to view the selected items in the list
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.