Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having 2 buttons if i click on button1 i would like to show view1 and if on button2 i would like to show view2

This is my design for multiview

XML
<asp:MultiView ID="MultiView2" runat="server" Visible="false">
                        <asp:View ID="View6" runat="server">
                            <asp:Label ID="lblAddress" runat="Server" Text="Address"></asp:Label>
                            <asp:DropDownList ID="ddlAddress" runat="Server">
                            </asp:DropDownList>
                            <br />
                            <br />
                            <asp:Label ID="lblAddress1" runat="server" Text="AddressLine1"></asp:Label>
                            &nbsp;
                            <asp:TextBox ID="txtAddrLine1" runat="server"></asp:TextBox>
                            <br />
                            <br />
                            <asp:Label ID="lblAddress2" runat="server" Text="AddressLine2"></asp:Label>
                            &nbsp;
                            <asp:TextBox ID="txtAddrLine2" runat="server"></asp:TextBox><br />
                            <br />
                            <asp:Label ID="lblCity1" runat="server" Text="City"></asp:Label>
                            &nbsp;
                            <asp:TextBox ID="txtCity1" runat="server"></asp:TextBox><br />
                            <br />
                            <asp:Label ID="lblStates" runat="server" Text="State"></asp:Label>
                            <asp:DropDownList ID="ddlStates" runat="server">
                            </asp:DropDownList><br />
                            <br />
                            <asp:Label ID="lblZip" runat="server" Text="ZipCode"></asp:Label>
                            <asp:TextBox ID="txtZip" runat="server"></asp:TextBox>
                            <br />
                            <br />
                            <asp:Label ID="lblCountry1" runat="server" Text="Country"></asp:Label>
                            <asp:TextBox ID="txtCountry1" runat="server"></asp:TextBox><br />
                            <br />
                            &nbsp;<asp:Button ID="btnSave" runat="server" Text="Save" CssClass="submit_buttons"
                                Width="54px" OnClick="btnSave_Click" /></asp:View>
                        <asp:View ID="viewPhone" runat="Server">
                            <asp:Label ID="lblPhonenoType" runat="server" Text="Phone Number Type"></asp:Label>
                            <asp:DropDownList ID="ddlPhnnoType" runat="server">
                            </asp:DropDownList>
                            <br />
                            <br />
                            <asp:Label ID="lblPhoneNumber1" runat="server" Text="PhoneNumber"></asp:Label>
                            <asp:TextBox ID="txtPhoneNumber" runat="server" Style="position: absolute"></asp:TextBox>
                        </asp:View>
                    </asp:MultiView>


i write my code as follows on every button_click

MIDL
MultiView2.Visible = true;
MultiView2.SetActiveView(View6);


For button2
MIDL
MultiView2.Visible = true;
MultiView2.SetActiveView(viewPhone);



But i am unable to show the viewphone i am getting the error as

The view View6 cannot be found inside MultiView2, the ActiveView must be a View control directly inside a MultiView.
Posted

1 solution

The view View6 cannot be found inside MultiView2
Sounds like the sequence of setting visibility and the ActiveView is not correct. This observation is based on your sentence that, 'at the time of viewphone, you get the above error'

Have a look here for details and examples of how to implement Multiviews[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900