WebPart ASP.Net Tutorial

<%@ Page Language="C#"%>

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
      WebParts.WebPartDisplayMode wpDisplayMode = Webpartmanager1.SupportedDisplayModes(DropDownList1.SelectedValue.ToString());
      Webpartmanager1.DisplayMode = wpDisplayMode;
    }
    protected void Page_Init(object sender, EventArgs e)
    {
      foreach (WebPartDisplayMode wpMode in Webpartmanager1.SupportedDisplayModes)
      {            
            string modeName = wpMode.Name;
            ListItem dd_ListItem = New ListItem(modeName, modeName);
            DropDownList1.Items.Add(dd_ListItem);
      }
    }



    Web Parts Example


    
        
        
        
            
                
                
                    Select mode:
                                         AutoPostBack="True" 
                     OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">        
                    
                
            

            
                

                
                
            
        

                    

Web Page


                                         LayoutOrientation="Horizontal">
                        
                                                         Title="Welcome to my web page!">
                             Welcome to the page!
                            
                        

                    
                

                    
                        
                                                         ImageUrl="~/Images/Kids.jpg" Width="150px" 
                             Title="My Kids">
                            
                        

                    
                

                    
                        
                                                         Title="Calendar">