无法获取MultiView控件更改视图 [英] Can't get multiview control to change views

查看:179
本文介绍了无法获取MultiView控件更改视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多视角控制,有两种观点。视图1是默认的视图,视图2是新的视图。当最终用户点击一个按钮,我想改变视图视图2。我似乎无法做到这一点无论如何,我走了。

I have a multiview control, that has two views. View1 is the default view, and View2 is the new view. When the end user click a button, I want to change the view to View2. I can't seem to achieve this anyway I go.

ASP.NET code:

ASP.NET Code:

 <asp:MultiView ID="MVOrder" runat="server">
                <asp:View ID="VOrderNow" runat="server">
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
               <ContentTemplate>
                    <table>
                <tr>
                    <td>
                        <asp:Label ID="LblInfo" runat="server"></asp:Label>
                    </td>
                    <td>
                        &nbsp;
    </td>
                    <td>&nbsp;
    </td>
                </tr>
                        <tr>
                            <td>
                                <asp:Label ID="LblDrink" runat="server"></asp:Label>
                            </td>
                            <td></td>
                            <td></td>
                        </tr>
                <tr>
                    <td>
                        <asp:Label ID="LblItemInfo" runat="server"></asp:Label>
                    </td>
                    <td>
                        &nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
            </table>
            <br />                
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
    </ContentTemplate>
            </asp:UpdatePanel>
                </asp:View>
                <asp:View runat="server" ID="VOrderComplete">

                    <table class="auto-style1">
                        <tr>
                            <td>&nbsp;</td>
                            <td>
                                <asp:Label ID="LblOrderComplete" runat="server"></asp:Label>
                            </td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>
                                <asp:Label ID="LblOrderNumberAgain" runat="server"></asp:Label>
                            </td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>
                                <asp:Label ID="LblOrderTimeAgain" runat="server"></asp:Label>
                            </td>
                            <td>&nbsp;</td>
                        </tr>
                    </table>

                </asp:View>
                <br/>
            </asp:MultiView>

按钮单击事件code:

Button Click Event Code:

protected void Button1_Click(object sender, EventArgs e)
        {
            //MVOrder.ActiveViewIndex = 1;
            MVOrder.SetActiveView(VOrderComplete);
        } 

页面加载code:

Page Load Code:

if (!IsPostBack)
            {
                MVOrder.SetActiveView(VOrderNow);
}

有人可以告诉我什么,我做错了什么?

Can someone please tell me what I am doing wrong?

推荐答案

我想你可能有一些额外的code,可能使这个无法正常工作。但是,根据您已经证明什么,这将发布并更新你的看法:

I think you might have some additional code that might make this not work properly. But based on what you've shown, this will post and update your view:

<asp:UpdatePanel ID="UpdatePanel2" runat="server">
    <ContentTemplate>
        <asp:MultiView ID="MVOrder" runat="server">
            <asp:View ID="VOrderNow" runat="server">
                <table>
                    <tr>
                        <td><asp:Label ID="LblInfo" runat="server" Text="asdfasdfasdf"></asp:Label></td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td><asp:Label ID="LblDrink" runat="server" Text="lmnoplmnop"></asp:Label></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td><asp:Label ID="LblItemInfo" runat="server" Text="iteminfo"></asp:Label></td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
                <br />
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
            </asp:View>
            <asp:View runat="server" ID="VOrderComplete">
                <table class="auto-style1">
                    <tr>
                        <td>&nbsp;</td>
                        <td><asp:Label ID="LblOrderComplete" runat="server" Text="ordercomplete"></asp:Label></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td><asp:Label ID="LblOrderNumberAgain" runat="server" Text="ordernumberagain"></asp:Label></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td><asp:Label ID="LblOrderTimeAgain" runat="server" Text="ordertimeagain"></asp:Label></td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
            </asp:View>
            <br />
        </asp:MultiView>
    </ContentTemplate>
</asp:UpdatePanel>

这篇关于无法获取MultiView控件更改视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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