Page

How to use XmlDataSource in asp.net

// ToolBoxControls.xml //


<?xml version="1.0" encoding="utf-8" ?>  
<StandardToolBox>  
  <Control Name="AdRotator" />  
  <Control Name="BulletedList" />  
  <Control Name="Button" />  
  <Control Name="Calendar" />  
  <Control Name="CheckBox" />  
  <Control Name="CheckBoxList" />  
  <Control Name="DropDownList" />  
  <Control Name="FileUpload" />  
  <Control Name="HiddenField" />  
  <Control Name="HyperLink" />  
  <Control Name="Image" />  
  <Control Name="ImageMap" />  
  <Control Name="ListBox" />  
  <Control Name="Literal" />  
  <Control Name="Localize" />  
  <Control Name="MultiView" />  
  <Control Name="View" />  
  <Control Name="Panel" />  
  <Control Name="PlaceHolder" />  
  <Control Name="RadioButton" />  
  <Control Name="RadioButtonList" />  
  <Control Name="Substitution" />  
  <Control Name="Table" />  
  <Control Name="TextBox" />  
  <Control Name="Wizard" />  
  <Control Name="XML" />  
</StandardToolBox>  




// Default.aspx //


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %> 
  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title>XmlDataSource Simple Example</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <asp:XmlDataSource ID="XmlDataSource1" runat="server"   
            DataFile="~/App_Data/ToolBoxControls.xml">  
        </asp:XmlDataSource>  
        <asp:Label ID="Label1" runat="server" Font-Size="Medium" ForeColor="Fuchsia">  
        </asp:Label>  
        <br /><br />  
        <asp:Label ID="Label2" runat="server" Text="Select your most favorite Standard ToolBox Control" Font-Size="Large" ForeColor="DarkRed">  
        </asp:Label>  
        <asp:RadioButtonList  
             ID="RadioButtonList1"  
             runat="server"  
             DataSourceID="XmlDataSource1"  
             DataMember="Control"  
             DataTextField="Name"  
             RepeatColumns="4"  
             AutoPostBack="true"  
             OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"  
             >  
        </asp:RadioButtonList>  
    </div>  
    </form>  
</body>  
</html>   


// Default.aspx.cs //



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {


    }


   protected void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)
 {  
        Label1.Text ="Your favorite control: "+ RadioButtonList1.SelectedItem.Text.ToString();  
    }  
}



// OUTPUT //




How to use SiteMapPath control in asp.net

// Web.sitemap //


<?xml version="1.0" encoding="utf-8" ?>  
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >  
  <siteMapNode url="Default.aspx" title="Home"  description="Home Page">  
    <siteMapNode url="StandardToolBox.aspx" title="Standard ToolBox Control"  description="Standard ToolBox Control">  
      <siteMapNode url="BulletedList.aspx" title="BulltedList Example"  description="BulltedList Control Simple Example" />  
      <siteMapNode url="CheckBox.aspx" title="CheckBox Example"  description="CheckBox Control Simple Example" />  
      <siteMapNode url="CheckBoxList.aspx" title="CheckBoxList Example"  description="CheckBoxList Control Simple Example" />  
      <siteMapNode url="Image.aspx" title="Image Control Example" description="Image Control Simple Example"/>  
    </siteMapNode>  
    <siteMapNode url="DataToolBox.aspx" title="Data ToolBox Control"  description="Data ToolBox Control">  
      <siteMapNode url="SqlDataSource.aspx" title="SqlDataSource Example"  description="SqlDataSource Simple Example" />  
      <siteMapNode url="XmlDataSource.aspx" title="XmlDataSource Example"  description="XmlDataSource Simple Example" />  
    </siteMapNode>  
  </siteMapNode>  
</siteMap>  



// Default.aspx //


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %> 
  
  
<!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 runat="server">  
    <title>SiteMapPath Control Simple Example</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />  
        <asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath>  
        <br /><br />  
        <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/SeaBeach.jpg" Height="300" Width="400" />  
    </div>  
    </form>  
</body>  
</html>  

How to use DropDownList AutoPostBack in asp.net c#

// Default.aspx // 



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %> 
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>How to use DropDownList AutoPostBack feature</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:Navy">DropDownList: AutoPostBack</h2>  
        <asp:Label   
             ID="Label1"  
             runat="server"  
             Font-Bold="true"  
             ForeColor="Purple"  
             Font-Size="Large"  
             >  
        </asp:Label>  
        <br /><br />  
        <asp:Label   
             ID="Label2"  
             runat="server"  
             Font-Bold="true"  
             ForeColor="OrangeRed"  
             Text="asp.net controls"  
             >  
        </asp:Label>  
        <asp:DropDownList   
             ID="DropDownList1"  
             runat="server"  
             AutoPostBack="true"  
             OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"  
             >  
             <asp:ListItem>HyperLink</asp:ListItem>  
             <asp:ListItem>PasswordRecovery</asp:ListItem>  
             <asp:ListItem>PlaceHolder</asp:ListItem>  
             <asp:ListItem>LoginName</asp:ListItem>  
             <asp:ListItem>Label</asp:ListItem>  
        </asp:DropDownList>  
    </div>  
    </form>  
</body>  
</html>  


// Default.aspx.cs //


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {


    }

    protected void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)  
    {  
        Label1.Text = "You Selected: " + DropDownList1.SelectedItem.Text;  
    }  
}


// OUTPUT //



How to use Click event in Button control

// Default.aspx //

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
   <title>Button example: how to use Click event in Button control</title>  
</head>  
<body>  
   <form id="form1" runat="server">  
   <div>  
       <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label>  
       <br /><br />  
       <asp:Button ID="Button1" runat="server" Text="Button1" OnClick="Button1_Click" />  
       <asp:Button ID="Button2" runat="server" Text="Button2" OnClick="Button2_Click" />  
   </div>  
   </form>  
</body>  
</html>  


// Default.aspx.cs //

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {


    }
  protected void Button1_Click(object sender, System.EventArgs e)  
    {  
        Label1.Text = "You clicked Button1";  
    }  
  
    protected void Button2_Click(object sender, System.EventArgs e)  
    {  
        Label1.Text = "You clicked Button2";  
    }  
}


// OUTPUT //




Blinking Text Using Javascript and ASP.NET

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Blinking text using Javascript</title>

    <script type="text/javascript">
function blinkIt() {
 if (!document.all) return;
 else {
   for(i=0;i<document.all.tags('blink').length;i++){
      s=document.all.tags('blink')[i];
      s.style.visibility=(s.style.visibility=='visible')    ?'hidden':'visible';
   }
 }
}
    </script>

    <style type="text/css">
        .blink
        {
            color: Red;
            font-weight: bold;
            font-family: Verdana, Tahoma;
            font-size: 14px;
        }
    </style>
</head>
<body onload="setInterval('blinkIt()',500)">
    <form id="form1" runat="server">
    <div>
        <blink class="blink">Am i blinking ???</blink>
    </div>
    </form>
</body>
</html>