Thursday 29 December 2011

AdRotator Example in ASP.NET using C#

AdRotator Example in ASP.NET using C#



AdRotator Example in ASP.NET using C#


Default.aspx Page
------------------->
<%@ 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></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:AdRotator ID="AdRotator1" Height="300px" Width="500px" runat="server" AdvertisementFile="~/XMLFile.xml" />
   
    </div>
    </form>
</body>
</html>




XmlFile.xml file
------------------->

<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
  <Ad>
    <ImageUrl>img/1.jpg</ImageUrl>
    <NavigateUrl>http://vsc-project.blogspot.com/</NavigateUrl>
    <AlternateText>Virani Science College Rajkot </AlternateText>

  </Ad>

  <Ad>
    <ImageUrl>img/2.jpg</ImageUrl>
    <NavigateUrl>http://vsc-project.blogspot.com/</NavigateUrl>
    <AlternateText>Virani Science College Rajkot </AlternateText>
  </Ad>
  <Ad>
    <ImageUrl>img/3.jpg</ImageUrl>
    <NavigateUrl>http://vsc-project.blogspot.com/</NavigateUrl>
    <AlternateText>Virani Science College Rajkot </AlternateText>
  </Ad>

  <Ad>
    <ImageUrl>img/4.jpg</ImageUrl>
    <NavigateUrl>http://vsc-project.blogspot.com/</NavigateUrl>
    <AlternateText>Virani Science College Rajkot </AlternateText>
  </Ad>
</Advertisements>







demo of AdRotator Example in ASP.NET using C#


Friday 16 December 2011

Check & UnCheck Item Using CheckBoxList and Display It's Value in Asp.Net




Check & UnCheck Item Using CheckBoxList and Display It's Value in Asp.Net




Default.aspx
-----------------------------

 <form id="form1" runat="server">
    <div>
   
        <asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True"
            onselectedindexchanged="CheckBoxList1_SelectedIndexChanged">
            <asp:ListItem>One</asp:ListItem>
            <asp:ListItem>Two</asp:ListItem>
            <asp:ListItem>Three</asp:ListItem>
        </asp:CheckBoxList>
   
    </div>
    <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Checked All</asp:LinkButton>
    <p>
        <asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">UnCheck All</asp:LinkButton>
    </p>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </form>
------------------------------

Default.aspx.cs
---------------

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

    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Label1.Text = "";
        foreach(ListItem li in CheckBoxList1.Items)
        {
            li.Selected = true;
            Label1.Text +="<br>"+ li.Text;
        }
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {

        foreach (ListItem li in CheckBoxList1.Items)
        {
            li.Selected = false;
            Label1.Text = "";
        }

    }
    protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string str = string.Empty;
        Label1.Text = "";
        foreach (ListItem li in CheckBoxList1.Items)
        {
          
           if(li.Selected)
           {
               str+="<br>"+ li.Text;
           }
        }
        Label1.Text = str;

    }
}








demo of Check & UnCheck Item Using CheckBoxList and Display It's Value in Asp.Net