.NET
  Home arrow .NET arrow Page 5 - Basic Usage of MultiView and View Controls...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Basic Usage of MultiView and View Controls in ASP.NET
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2006-11-08

    Table of Contents:
  • Basic Usage of MultiView and View Controls in ASP.NET
  • Creating a web page with MultiView and View controls
  • Design time properties of View Control
  • Container Properties of View and MultiView Controls
  • Presenting a user preferred View

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Basic Usage of MultiView and View Controls in ASP.NET - Presenting a user preferred View


    (Page 5 of 5 )

    One of the advantages of using the MultiView/View pair of controls is the ability to present a view based on user preference without going to another page. The next picture shows a web page with a MultiView Control containing two View controls. Depending on the choice made by the user, one or the other view will be presented to the user. The web page Choices.aspx shown next has two views, one showing an animal, and the other showing a flower.

    The radio button group with the GroupName Test offers the user an opportunity to make a choice. The user makes a choice and clicks the What do you want to see? button. The code shown here displays the View based on user choice.

     Protected Sub Button1_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    If RadioButton1.Checked Then
    'MultiView1.ActiveViewIndex = 0
    MultiView1.SetActiveView(View1)
    End If
    If RadioButton2.Checked Then
    MultiView1.SetActiveView(View2)
    'MultiView1.ActiveViewIndex = 1
    End If
    End Sub
    

    Only after clicking the button is one or the other view displayed, otherwise you will see the controls on the page, but not the controls on the views. The next picture shows the display when View1 is chosen.

    Moving from View to View from within the MultiView Control

    When there are a number of views it is possible to move from one view to another within the views using the properties, methods and events raised of the View Control or controls in the views. The next design shows a web page with two views.

    View1 is displayed because the ActiveViewIndex is set to 0 in the MultiView control. When the "Go to View 2(Button2)" is clicked, the view displayed changes from View1 to View2 following the code shown in the next paragraph. In View 2, when the 'Greet' button is clicked the greeting's text is displayed in the textbox shown in View2.

    Protected Sub Button1_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    TextBox1.Text = "Welcome to View2"
    End Sub
    Protected Sub Button2_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button2.Click
    MultiView1.ActiveViewIndex = 1
    End Sub
    

    Properties and methods of the MultiView Control

    Intellisense support provides support for coding as shown, revealing the available properties and methods of the MultiView Control. However, declarative syntax can also be used. The next picture shows how you may access the properties and methods from the code page. The paragraph that follows the declarative syntax of the MultiView control is copied from Microsoft's documentation.

    <asp:MultiView
    ActiveViewIndex="integer"
    EnableTheming="True|False"
    EnableViewState="True|False"
    ID="string"
    OnActiveViewChanged="ActiveViewChanged event handler"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    runat="server"
    SkinID="string"
    Visible="True|False"/>
    

    Summary

    MultiVew and View controls add functionality to web pages similar to the wizard control discussed in a previous tutorial. Only some of the very basic features are discussed; some of the properties, such as the CommndName property which can automatically switch from one view to the next without writing any code, are not discussed.

    While placing controls on the Views some of the functionality needed for placement, such as alignment and spacing of controls from the menu item Format, are not available, but can be set using the property pages for the controls. The functionality provided by these controls may be used for taking surveys, presenting user defined and user based views.

    It is possible sometimes that even when the View is added it does not show up in the drop-down in the .vb page. In this case it is necessary to close the application and re-open. Reproducibility of this errant behavior has not been tested.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Persisting user preferences is not a trivial task but users are more and more used...
     

    .NET ARTICLES

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT