0

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:

enter image description here

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.

4

2 回答 2

5

我认为当您在 Page_Load() 中加载页面内容时,请确保在检查是否是回发请求后加载。如果不是回发请求,请加载事件。

IE :-

    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
       {

        //load the contents of the page/listbox here.

       }

}
于 2013-10-18T11:10:54.633 回答
1
<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"];

    }

我能够查看列表中的选定项目

于 2013-10-18T10:28:41.913 回答