Page

How to use ListView control in asp.net

<%@ Page Language="C#" AutoEventWireup="true" %>  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<script runat="server">  
      
</script>  
<html xmlns="http://www.w3.org/1999/xhtml" >  
<head id="Head1" runat="server">  
    <title>ListView control - how to use ListView control in asp.net</title>  
    <style type="text/css">  
        .TableCSS  
        {  
            border-style:none;  
            background-color:DarkOrange;  
            width: 600px;  
            }  
        .TableHeader  
        {  
            background-color:OrangeRed;  
            color:Snow;  
            font-size:large;  
            font-family:Verdana;  
            }      
        .TableData  
        {  
            background-color:Orange;  
            color:Snow;  
            font-family:Courier New;  
            font-size:medium;  
            font-weight:bold;  
            }                      
    </style>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:Navy; font-style:italic;">ListView Control Example: How To Use ListView Control</h2>  
        <hr width="550" align="left" color="PowderBlue" />  
        <asp:SqlDataSource   
            ID="SqlDataSource1"  
            runat="server"  
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"  
            SelectCommand="Select ProductID, ProductName From products Order By ProductID"  
            >  
        </asp:SqlDataSource>  
        <br />  
        <asp:ListView   
            ID="ListView1"  
            runat="server"  
            DataSourceID="SqlDataSource1"  
            >  
            <LayoutTemplate>  
                <table runat="server" class="TableCSS">  
                    <tr runat="server" class="TableHeader">  
                        <td runat="server">Product ID</td>  
                        <td runat="server">Product Name</td>  
                    </tr>  
                    <tr id="ItemPlaceholder" runat="server">  
                    </tr>  
                    <tr runat="server">  
                        <td runat="server" colspan="2">  
                            <asp:DataPager ID="DataPager1" runat="server">  
                                <Fields>  
                                    <asp:NextPreviousPagerField ButtonType="Link" />  
                                    <asp:NumericPagerField />  
                                    <asp:NextPreviousPagerField ButtonType="Link" />  
                                </Fields>  
                            </asp:DataPager>  
                        </td>  
                    </tr>  
                </table>  
            </LayoutTemplate>  
            <ItemTemplate>  
                <tr class="TableData">  
                    <td>  
                        <asp:Label   
                            ID="Label1"  
                            runat="server"  
                            Text='<%# Eval("ProductID")%>'  
                            >  
                        </asp:Label>  
                    </td>  
                    <td>  
                        <asp:Label   
                            ID="Label2"  
                            runat="server"  
                            Text='<%# Eval("ProductName")%>'  
                            >  
                        </asp:Label>  
                    </td>  
                </tr>                  
            </ItemTemplate>  
        </asp:ListView>  
    </div>  
    </form>  
</body>  
</html>  

How to use table for ListView layout in asp.net

<%@ Page Language="C#" AutoEventWireup="true" %>  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<script runat="server">  
      
</script>  
<html xmlns="http://www.w3.org/1999/xhtml" >  
<head id="Head1" runat="server">  
    <title>ListView LayoutTemplate table - how to use table for ListView layout</title>  
    <style type="text/css">  
        .TableCSS  
        {  
            border-style:none;  
            background-color:SeaGreen;  
            width: 600px;  
            }  
        .TableHeader  
        {  
            background-color:MediumSeaGreen;  
            color:Snow;  
            font-size:large;  
            font-family:Verdana;  
            height:45px;  
            text-align:center;  
            }      
        .TableData  
        {  
            background-color:DarkSeaGreen;  
            color:Snow;  
            font-family:Courier New;  
            font-size:medium;  
            font-weight:bold;  
            height:30px;  
            }    
        .TablePager  
        {  
            background-color:Green;  
            height:45px;  
            }                                
        .PagerButtonCSS  
        {  
            color:DarkGreen;  
            height:35px;  
            font-weight:bold;  
            font-family:Comic Sans MS;  
            }      
        .NumericButtonCSS  
        {  
            font-size:x-large;  
            font-family:Courier New;  
            color:Snow;  
            font-family:Comic Sans MS;  
            font-weight:bold;  
            }    
        .CurrentPageLabelCSS  
        {  
            font-size:xx-large;  
            font-family:Comic Sans MS;  
            color:White;  
            font-weight:bold;  
            }   
        .NextPreviousButtonCSS  
        {  
            font-size:large;  
            font-family:Courier New;  
            color:LawnGreen;  
            font-weight:bold;  
            }                                           
    </style>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:DeepPink; font-style:italic;">ListView Example: How To Use Table Type Layout</h2>  
        <hr width="575" align="left" color="Pink" />  
        <asp:SqlDataSource   
            ID="SqlDataSource1"  
            runat="server"  
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"  
            SelectCommand="Select ProductName, UnitPrice From products Order By ProductName"  
            >  
        </asp:SqlDataSource>  
        <br />  
        <asp:ListView   
            ID="ListView1"  
            runat="server"  
            DataSourceID="SqlDataSource1"  
            >  
            <LayoutTemplate>  
                <table runat="server" class="TableCSS">  
                    <tr runat="server" class="TableHeader">  
                        <td runat="server">Product Name</td>  
                        <td runat="server">Unit Price</td>  
                    </tr>  
                    <tr id="ItemPlaceholder" runat="server">  
                    </tr>  
                    <tr runat="server" class="TablePager">  
                        <td runat="server" colspan="2">  
                            <asp:DataPager ID="DataPager1" runat="server">  
                                <Fields>  
                                    <asp:NextPreviousPagerField   
                                        ButtonType="Button"   
                                        ShowFirstPageButton="true"  
                                        ShowPreviousPageButton="false"  
                                        ShowNextPageButton="true"  
                                        ButtonCssClass="PagerButtonCSS"  
                                        />  
                                    <asp:NumericPagerField   
                                        NumericButtonCssClass="NumericButtonCSS"  
                                        NextPreviousButtonCssClass="NextPreviousButtonCSS"  
                                        CurrentPageLabelCssClass="CurrentPageLabelCSS"  
                                        />  
                                    <asp:NextPreviousPagerField   
                                        ButtonType="Button"  
                                        ShowNextPageButton="false"  
                                        ShowLastPageButton="true"  
                                        ButtonCssClass="PagerButtonCSS"  
                                        />  
                                </Fields>  
                            </asp:DataPager>  
                        </td>  
                    </tr>  
                </table>  
            </LayoutTemplate>  
            <ItemTemplate>  
                <tr class="TableData">  
                    <td>  
                        <asp:Label   
                            ID="Label1"  
                            runat="server"  
                            Text='<%# Eval("ProductName")%>'  
                            >  
                        </asp:Label>  
                    </td>  
                    <td align="center">  
                        <asp:Label   
                            ID="Label2"  
                            runat="server"  
                            Text='<%# Eval("UnitPrice")%>'  
                            >  
                        </asp:Label>  
                    </td>  
                </tr>                  
            </ItemTemplate>  
        </asp:ListView>  
    </div>  
    </form>  
</body>  
</html>  


OUTPUT



Horizontal Navigation Bar Example in HTML

/* HTML Document */


<h2 class="offscreen">W3C Web Resources</h2> 
<div id="hmenu"> 
<ul> 
  <li><a href="http://www.sourcecodernp.blogspot.com">HOME</a></li> 
  <li><a href="http://www.sourcecodernp.blogspot.com">XML</a></li> 
  <li><a href="http://www.sourcecodernp.blogspot.com">HTML</a></li> 
  <li><a href="http://www.sourcecodernp.blogspot.com">C & C++</a></li> 
  <li><a href="http://www.sourcecodernp.blogspot.com">ASP.Net</a></li> 
  <li><a href="http://www.sourcecodernp.blogspot.com">PROJECT</a></li> 
  <li><a href="http://www.sourcecodernp.blogspot.com">ABOUT US</a></li> 
</ul>   
</div> 


/* CSS Document */ 


.offscreen { 
  position: absolute; 
  top: -30em; 
  left: -300em; 


div#hmenu { 
   margin: 0; 
   padding: .3em 0 .3em 0; 
   background: #ddeebb; 
   width: 100%; 
   text-align: center; 


div#hmenu ul { 
   list-style: none; 
   margin: 0; 
   padding: 0; 


div#hmenu ul li { 
   margin: 0; 
   padding: 0; 
   display: inline; 


div#hmenu ul a:link{ 
   margin: 0; 
   padding: .3em .4em .3em .4em; 
   text-decoration: none; 
   font-weight: bold; 
   font-size: medium; 
   color: #004415; 


div#hmenu ul a:visited{ 
   margin: 0; 
   padding: .3em .4em .3em .4em; 
   text-decoration: none; 
   font-weight: bold; 
   font-size: medium; 
   color: #227755; 


div#hmenu ul a:active{ 
   margin: 0; 
   padding: .3em .4em .3em .4em; 
   text-decoration: none; 
   font-weight: bold; 
   font-size: medium; 
   color: #227755; 


div#hmenu ul a:hover{ 
   margin: 0; 
   padding: .3em .4em .3em .4em; 
   text-decoration: none; 
   font-weight: bold; 
   font-size: medium; 
   color: #f6f0cc; 
   background-color: #227755; 
}

How to use profile serialization in asp.net

//ProfileSerialization.aspx


<%@ Page Language="C#" %>  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  
<script runat="server">  
    protected void Page_Load(object sender, System.EventArgs e)  
    {   
        if(!this.IsPostBack)  
        {  
            Profile.Name = "KakPakhi";  
            Profile.City = "Rome";  
            Profile.JoinDate = DateTime.Now;  
            Profile.Save();  
        }  
    }  
    protected void Button1_Click(object sender, System.EventArgs e) {  
        Label1.Text = "Profile data read...<br /><br />";  
        Label1.Text += "<i>Name: " + Profile.Name;  
        Label1.Text += "<br />City: " + Profile.City;  
        Label1.Text += "<br />Join Date: " + Profile.JoinDate.ToLongDateString() + "</i>";  
    }  
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>How to use profile serialization in asp.net (serializeAs String,Xml,Binary)</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:Navy">asp.net Profile example: Profile Serialization</h2>  
        <asp:Label   
             ID="Label1"   
             runat="server"   
             Font-Size="Large"   
             Font-Bold="true"  
             ForeColor="SeaGreen"  
             >  
        </asp:Label>  
        <br /><br />  
        <asp:Button   
             ID="Button1"   
             runat="server"   
             Font-Bold="true"   
             ForeColor="SteelBlue"  
             Text="Show Profile"  
             OnClick="Button1_Click"  
             />  
    </div>  
    </form>  
</body>  
</html>  





//web.config [Modified Parts]


<authentication mode="Windows" />  
<profile>  
  <properties>  
    <add name="Name" type="System.String" serializeAs="String"/>  
    <add name="City" type="System.String" serializeAs="Xml"/>  
    <add name="JoinDate" type="System.DateTime" serializeAs="Binary"/>  
  </properties>  
</profile>  

Ajax HoverMenuExtender - How to use HoverMenuExtender in asp.net ajax

<%@ Page Language="C#" AutoEventWireup="true" %>  
  
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<script runat="server">  
    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)  
    {  
        Label1.ForeColor = System.Drawing.Color.FromName(RadioButtonList1.SelectedItem.Text);  
    }  
</script>  
<html xmlns="http://www.w3.org/1999/xhtml" >  
<head id="Head1" runat="server">  
    <title>Ajax HoverMenuExtender - How to use HoverMenuExtender in asp.net ajax</title>  
    <style type="text/css">  
        .PanelCSS  
        {  
            visibility:hidden;  
            }  
    </style>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:DeepPink; font-style:italic;">Ajax Control Toolkit Example: Using HoverMenuExtender</h2>  
        <hr width="550" align="left" color="Pink" />  
        <asp:ScriptManager   
            ID="ScriptManager1"  
            runat="server"  
            >  
        </asp:ScriptManager>  
        <cc1:HoverMenuExtender   
            ID="HoverMenuExtender1"  
            runat="server"  
            TargetControlID="Label1"  
            PopupControlID="Panel1"  
            PopupPosition="Bottom"  
            >  
        </cc1:HoverMenuExtender>  
        <br /><br />  
        <asp:Label   
            ID="Label1"  
            runat="server"  
            Text="Color changeable label."  
            Font-Size="XX-Large"  
            Font-Names="Comic Sans MS"  
            >  
        </asp:Label>  
        <asp:Panel   
            ID="Panel1"  
            runat="server"  
            Width="300"  
            BorderColor="Gray"  
            BorderWidth="1"  
            CssClass="PanelCSS"  
            >  
            <asp:RadioButtonList   
                ID="RadioButtonList1"  
                runat="server"  
                RepeatColumns="3"  
                OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"  
                AutoPostBack="true"  
                >  
                <asp:ListItem>Tan</asp:ListItem>  
                <asp:ListItem>Crimson</asp:ListItem>  
                <asp:ListItem>DarkBlue</asp:ListItem>  
                <asp:ListItem>SeaGreen</asp:ListItem>  
                <asp:ListItem>OrangeRed</asp:ListItem>  
                <asp:ListItem>Magenta</asp:ListItem>  
                <asp:ListItem>DeepPink</asp:ListItem>  
            </asp:RadioButtonList>  
        </asp:Panel>  
    </div>  
    </form>  
</body>  
</html>  

asp.net radiobuttonlist vertical alignment

<%@ Page Language="C#" AutoEventWireup="true"%>      
        
<!DOCTYPE html>          
<script runat="server">  
    protected void Page_Load(object sender, EventArgs e)  
    {   
        if(!Page.IsPostBack)  
        {  
            RadioButtonList1.Items.Add(new ListItem("Northern Mockingbird", "1"));  
            RadioButtonList1.Items.Add(new ListItem("Gray Catbird", "2"));  
            RadioButtonList1.Items.Add(new ListItem("Sage Thrasher", "3"));  
            RadioButtonList1.Items.Add(new ListItem("Socorro Mockingbird", "4"));  
            RadioButtonList1.Items.Add(new ListItem("Brown Thrasher", "5"));  
        }  
    }  
</script>          
          
<html xmlns="http://www.w3.org/1999/xhtml">          
<head id="Head1" runat="server">          
    <title>asp.net radiobuttonlist vertical alignment</title>  
    <style type="text/css">  
        .radiobuttonlist {  
        }  
        .radiobuttonlist td{  
            border:1px solid green;  
            height:50px;  
            vertical-align:bottom;  
        }  
    </style>  
</head>          
<body>          
    <form id="form1" runat="server">          
    <div>          
        <h2 style="color:MidnightBlue; font-style:italic;">          
            asp.net example - radiobuttonlist vertical alignment  
        </h2>          
        <hr width="550" align="left" color="Gainsboro" />          
        <asp:Label         
            ID="Label1"         
            runat="server"        
            Font-Size="Large"  
            Width="350"  
            Text="radiobuttonlist vertical alignment bottom"  
            >        
        </asp:Label>        
        <br /><br />  
        <asp:RadioButtonList   
            ID="RadioButtonList1"  
            runat="server"  
            RepeatDirection="Vertical"  
            AutoPostBack="true"  
            RepeatLayout="Table"  
            CssClass="radiobuttonlist"  
            >  
        </asp:RadioButtonList>    
    </div>          
    </form>          
</body>          
</html>  

asp.net radiobuttonlist vertical spacing

<%@ Page Language="C#" AutoEventWireup="true"%>      
        
<!DOCTYPE html>          
<script runat="server">  
    protected void Page_Load(object sender, EventArgs e)  
    {   
        if(!Page.IsPostBack)  
        {  
            RadioButtonList1.Items.Add(new ListItem("Asian Glossy Starling", "1"));  
            RadioButtonList1.Items.Add(new ListItem("Golden Myna", "2"));  
            RadioButtonList1.Items.Add(new ListItem("Hill Myna", "3"));  
            RadioButtonList1.Items.Add(new ListItem("Orange-headed Thrush", "4"));  
            RadioButtonList1.Items.Add(new ListItem("Blue Whistling-thrush", "5"));  
        }  
    }  
</script>          
          
<html xmlns="http://www.w3.org/1999/xhtml">          
<head id="Head1" runat="server">          
    <title>asp.net radiobuttonlist vertical spacing</title>  
    <style type="text/css">  
        .radiobuttonlist {  
        }  
        .radiobuttonlist td{  
            height:45px;  
            vertical-align:middle;  
        }  
    </style>  
</head>          
<body>          
    <form id="form1" runat="server">          
    <div>          
        <h2 style="color:MidnightBlue; font-style:italic;">          
            asp.net example - radiobuttonlist vertical spacing  
        </h2>          
        <hr width="550" align="left" color="Gainsboro" />          
        <asp:Label         
            ID="Label1"         
            runat="server"        
            Font-Size="Large"  
            Width="350"  
            Text="select an item from radiobuttonlist....."  
            >        
        </asp:Label>        
        <br /><br />  
        <asp:RadioButtonList   
            ID="RadioButtonList1"  
            runat="server"  
            RepeatDirection="Vertical"  
            AutoPostBack="true"  
            RepeatLayout="Table"  
            CssClass="radiobuttonlist"  
            >  
        </asp:RadioButtonList>    
    </div>          
    </form>          
</body>          
</html>