在客户端列表框挑剔的变化出现在服务器端withen ASP向导不工作 [英] listbox changes in client side nit appear in server side withen asp wizard not working

查看:84
本文介绍了在客户端列表框挑剔的变化出现在服务器端withen ASP向导不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个ListBox控件withen一个ASP向导
那是code:

i have two listbox control withen an asp wizard that is the code :

<asp:Wizard DisplaySideBar="False" ID="Wizard1" runat="server" ActiveStepIndex="1" BackColor="#F7F6F3" BorderColor="#CCCCCC" 
                                    BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
                                    Font-Size="0.8em" OnFinishButtonClick="OnFinishButtonClick"
                                    OnNextButtonClick="savePassword"  >

<HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True" 
    Font-Size="0.9em" ForeColor="White" HorizontalAlign="Left" />
<NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
    BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" 
    ForeColor="#284775" />
<SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" />
<SideBarStyle BackColor="#7C6F57" BorderWidth="0px" Font-Size="0.9em" 
    VerticalAlign="Top" />

<StepNavigationTemplate>
    <asp:Button ID="StepPreviousButton" runat="server" CausesValidation="False" 
        CommandName="MovePrevious" Text="Previous" Width="70px" BackColor="#FFFBFF" BorderColor="#CCCCCC"
        BorderStyle="Solid" Font-Names="Verdana"  ForeColor="#284775" BorderWidth="1px" Font-Size="0.8em"/>
    <asp:Button ID="StepNextButton" runat="server" CommandName="MoveNext" 
        Text="Next" Width="70px" BackColor="#FFFBFF" BorderColor="#CCCCCC"
        BorderStyle="Solid" Font-Names="Verdana"  ForeColor="#284775" BorderWidth="1px" Font-Size="0.8em"  />
</StepNavigationTemplate>    
<StepStyle BorderWidth="0px" ForeColor="#5D7B9D" /> 
<WizardSteps>
    <asp:WizardStep ID="WizardStep1" runat="server" Title="User Data"  
        StepType="Start">
        <%-- some code --%>
    </asp:WizardStep>
    <asp:WizardStep ID="WizardStep2" runat="server" Title="Company Data" 
        StepType="Step">
        **<table>

            <tr>
                <td class="style4">
                    <font face="tahoma" style="font-weight: bold; font-size: 10px;">Categories<div 
                        class="important">
                        *</div>
                    </font>
                </td>
                <td class="style9">
                <asp:ListBox ID="registerCompCats" runat="server" CssClass="ListBox1"
                ClientIDMode="Static" DataTextField="value" DataValueField="key"
                Rows="5" size="5" style="width:135px; size:5px;" SelectionMode="Multiple" ></asp:ListBox>
                    &nbsp;&nbsp;&nbsp;</td>
                <td class="style1">
                    <table>
                        <tr>
                            <td style="padding-left: 20px;">

                                <img id="addCat" 
                        src="images/buttons/btn_addCat.jpg" title="Add Category"  />
                            </td>
                        </tr>
                        <tr>
                            <td style="padding-left: 20px;">
                                <img id="removeCat" 
                        src="images/buttons/btn_removeCat.jpg" title="Remove Category" />
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                <asp:ListBox ID="registerCompAcats" runat="server" CssClass="ListBox2" 
                ClientIDMode="Static" DataTextField="value" DataValueField="key" ViewStateMode="Enabled"
                Rows="5" size="5" style="width:135px; size:5px; margin-top: 0px;" SelectionMode="Multiple"
                 ></asp:ListBox>
                    &nbsp;<asp:RequiredFieldValidator ID="registerCompAcatsValidator" runat="server" 
                        ControlToValidate="registerCompAcats" Display="None" ErrorMessage="categories required "></asp:RequiredFieldValidator></td>
            </tr>

        </table>**
    </asp:WizardStep>
    <asp:WizardStep ID="WizardStep3" runat="server" Title="Final Data" StepType="Finish">
         <%-- some code --%>
    </asp:WizardStep>
</WizardSteps>

第一列表框的数据配备了页面加载,第二个由$ P $通过使用Java脚本鳕鱼pssing中间的按钮来完成的数​​据,那就是code:

data of first listbox come with page loading , data of second one done by pressing the button in the middle by using java script cod , and that is the code :

$(function () {




//            for (var i = 0; i < x.length; i++) {
//                $(x[i]).keyup(function (event) {
//                    if (event.keyCode == 13) {
//                        $(".SearchBarControlBtn").click();
//                    }
//                });

//            }
$('#addCat').click(function () {
    $(".ListBox1 > option:selected").appendTo(".ListBox2");        
    sortlist(".ListBox1 > option");
    sortlist(".ListBox2 > option");
    selectAll();

});


$('#removeCat').click(function () {
    $(".ListBox2 > option:selected").appendTo(".ListBox1");
    sortlist(".ListBox1 > option");
    sortlist(".ListBox2 > option");
    selectAll();


});

});

这code效果很好页面和两个列表框之间的数据移动
但是当我去后面code页面保存第二列表框的内容我觉得空

that code works well in page and data moved between both listbox but when i go to page behind code to save content of second listbox i find it empty

问题出在哪里?

请注意:与同code(HTML,JavaScript的),但除去步骤向导在第二个列表框中显示的数据以及

note : with the same code (HTML , javascript ) but removing step wizard the data in the second listbox appear well

推荐答案

是的,因为他们不是在ViewState中,他们将是空的。
你可以做一些与阿贾克斯回发到列表中添加列表项。
然后,他们会在你的列表框。
你可以在这里阅读更多的信息:
http://msdn.microsoft.com/en-us/library/ms972976.aspx

Yes, they will be empty because they are not in the viewstate. You can do some ajax with postback to add list items in the list. Then they will be in your listbox. You can read here for more info: http://msdn.microsoft.com/en-us/library/ms972976.aspx

这篇关于在客户端列表框挑剔的变化出现在服务器端withen ASP向导不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆