Sunday 18 May 2014

dynamic slider using li

<div class="rslides_container">
<ul class="rslides" id="slider">
                     <asp:Repeater ID="Repeater2" runat="server">
            <ItemTemplate>
            <li>              
            <asp:Image ID="Image2" Width="640px" Height="300px" ImageUrl='<%#Eval("Image") %>' runat="server" />
            </li>
            </ItemTemplate>
            </asp:Repeater>
</ul>
</div>


Codes
public void show1()
    {
        string str = "select image from product";
        da = new SqlDataAdapter(str, con);
        dt = new DataTable();
        da.Fill(dt);
        Repeater2.DataSource = dt;
        Repeater2.DataBind();

    }

Thursday 15 May 2014

Holiday Calender List in ASP.Net C#

Holiday Calender List in ASP.Net C#

Well so most of the time as a developer we get requirement to develop a calender with
 holidays list, so here i have tried to explain this in very simple way. Just follow step by
 step to develop this. 

Open Microsoft Visual Studio --> Click File --> New --> Website --> Enter file Name --> OK 


Lets write few code on page 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 id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Calendar ID="Calendar1" runat="server" Height="444px" Width="100%"
OnDayRender="Calendar1_DayRender"
            OnSelectionChanged="Calendar1_SelectionChanged"OnVisibleMonthChanged=
"Calendar1_VisibleMonthChanged"
            DayNameFormat="Full" ForeColor="#000099" NextMonthText="">
            <DayHeaderStyle BackColor="#666699" ForeColor="Maroon" />
            <DayStyle BackColor="#CCCCCC" Font-Bold="True" Font-Italic="False"
 ForeColor="#000066" />
            <SelectedDayStyle BackColor="#9999FF" Font-Bold="True" ForeColor="Maroon" />
            <WeekendDayStyle BackColor="#999966" Font-Bold="True" ForeColor="#990000" />
        </asp:Calendar>
        <asp:Label ID="LabelAction" runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>

Now write the below code in .cs page.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
public partial class _Default : System.Web.UI.Page
{
    Hashtable HolidayList;
    protected void Page_Load(object sender, EventArgs e)
    {
        HolidayList = Getholiday();
        Calendar1.Caption = "Calender";
        Calendar1.FirstDayOfWeek = FirstDayOfWeek.Monday;
        Calendar1.NextPrevFormat = NextPrevFormat.FullMonth;
        Calendar1.TitleFormat = TitleFormat.Month;
        Calendar1.ShowGridLines = true;
        Calendar1.DayStyle.Height = new Unit(50);
        Calendar1.DayStyle.Width = new Unit(150);
        Calendar1.DayStyle.HorizontalAlign = HorizontalAlign.Center;
        Calendar1.DayStyle.VerticalAlign = VerticalAlign.Middle;

        //Calendar1.OtherMonthDayStyle.BackColor = System.Drawing.Color.AliceBlue;
    }
    private Hashtable Getholiday()
    {
        Hashtable holiday = new Hashtable();
        holiday["1/1/2013"] = "New Year";
        holiday["1/5/2013"] = "Guru Govind Singh Jayanti";
        holiday["1/8/2013"] = "Muharam (Al Hijra)";
        holiday["1/14/2013"] = "Pongal";
        holiday["1/26/2013"] = "Republic Day";
        holiday["2/23/2013"] = "Maha Shivaratri";
        holiday["3/10/2013"] = "Milad un Nabi (Birthday of the Prophet";
        holiday["3/21/2013"] = "Holi";
        holiday["3/21/2013"] = "Telugu New Year";
        holiday["4/3/2013"] = "Ram Navmi";
        holiday["4/7/2013"] = "Mahavir Jayanti";
        holiday["4/10/2013"] = "Good Friday";
        holiday["4/12/2013"] = "Easter";
        holiday["4/14/2013"] = "Tamil New Year and Dr Ambedkar Birth Day";
        holiday["5/1/2013"] = "May Day";
        holiday["5/9/2013"] = "Buddha Jayanti and Buddha Purnima";
        holiday["6/24/2013"] = "Rath yatra";
        holiday["8/13/2013"] = "Krishna Jayanthi";
        holiday["8/14/2013"] = "Janmashtami";
        holiday["8/15/2013"] = "Independence Day";
        holiday["8/19/2013"] = "Parsi New Year";
        holiday["8/23/2013"] = "Vinayaka Chaturthi";
        holiday["9/2/2013"] = "Onam";
        holiday["9/5/2013"] = "Teachers Day";
        holiday["9/21/2013"] = "Ramzan";
        holiday["9/27/2013"] = "Ayutha Pooja";
        holiday["9/28/2013"] = "Vijaya Dasami (Dusherra)";
        holiday["10/2/2013"] = "Gandhi Jayanti";
        holiday["10/17/2013"] = "Diwali & Govardhan Puja";
        holiday["10/19/2013"] = "Bhaidooj";
        holiday["11/2/2013"] = "Guru Nanak Jayanti";
        holiday["11/14/2013"] = "Children's Day";
        holiday["11/28/2013"] = "Bakrid";
        holiday["12/25/2013"] = "Christmas";
        holiday["12/28/2013"] = "Muharram";
        return holiday;
    }
    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        if (HolidayList[e.Day.Date.ToShortDateString()] != null)
        {
            Literal literal1 = new Literal();
            literal1.Text = "<br/>";
            e.Cell.Controls.Add(literal1);
            Label label1 = new Label();
            label1.Text = (string)HolidayList[e.Day.Date.ToShortDateString()];
            label1.Font.Size = new FontUnit(FontSize.Small);
            e.Cell.Controls.Add(label1);
        }
    }
    protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
    {
        LabelAction.Text = "Month changed to :" + e.NewDate.ToShortDateString();
    }
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        LabelAction.Text = "Date changed to :" + Calendar1.SelectedDate.ToShortDateString();
    }
}

Wednesday 14 May 2014

create bootable usb pendrive

HOW TO CREATE BOOTABLE USB PEN DRIVE FOR WINDOWS 7 AND 8. BY TARUN KUMAR

HOW TO CREATE BOOTABLE USB PEN DRIVE FOR WINDOWS 7 AND 8.

Bootable Usb Pen drive is simple and fast way to format your PC or Laptop. After formatting you can easily install windows in your system. Bootable usb pendrive has several advantage as like easy formatting, easy copy and past windows file and after that easy to installing windows. Now we are discussing some important step to make bootable pen drive.

Advantages :

  • Installing process through bootable usb pen drive is much better then DVD.
  • Easy to carrying.
  • Easy to handle and no need to expert. 
  • Best option for all who haven’t DVD drive in his PC or Laptop.

Requirement :

  • Blank (empty) Pen drive with minimum capacity of 4Gb.

Process :


Step 1 :

Plug-in your pen drive in Laptop.

Step 2 :

Go to Start  >> Type Cmd  (in search program and file [Press Enter]
After pressing Enter command prompt will open.
On your Caps lock

Step 3 :

Type  DISKPART   [Press Enter]
bootable usb pen drive

Step 4 :

Type  LIST  DISK    [Press Enter]
It will show all available disk in your system. Disk 0 is usually hard disk of your system. In my case Disk 1 is Usb pen drive (This can be different in your case so plz make sure )

Step 5 :

Type  SELECT  DISK  1  [Press Enter]

Step 6 :

Type  CLEAN  [Press Enter]

Step 7 :

Type  CREATE  PARTITION  PRIMARY   [Press Enter]

Step 8 :

Type  SELECT  PARTITION  1  [Press Enter]

Step 9 :

Type  ACTIVE  [Press Enter]

Step 10 :

Type FORMAT  FS=NTFS  [Press Enter]
Wait Until 100% complete.

Step 11 :

Type  ASSIGN  [Press Enter]

Step 12 :

Type EXIT [Press Enter]
Bootable Usb Pen driveNow bootable usb pen drive is ready to use. After making this copy and paste windows 7 or 8 in your pen drive. It is easiest way to install windows 7 or 8 in your  system.
When you want to install windows, plug-in bootable pen drive and restart the system and press boot function key as per different system (f1——-f12) .

Note :

Before making bootable usb pen drive plz make sure that you are using only one Pen drive at this time. This process is only for windows 7 or 8 not for Xp.

How to show the gridview header when datatable is empty

Output:


Aspx Page 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="VP_Industries.WebForm2" %>

<!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>

    <style type="text/css">
       
.Gridview
{
        font-family:Verdana;
        font-size:10pt;
        font-weight:normal;
        color:black;
        width:300px;
}

</style>

</head>
<body>
    <form id="form1" runat="server">
    <div>
   

 <asp:GridView ID="gvdata" runat="server" CssClass="Gridview" ShowHeaderWhenEmpty="true"AutoGenerateColumns="false" HeaderStyle-BackColor="#7779AF" HeaderStyle-ForeColor="White">
<Columns>
<asp:BoundField DataField="username" HeaderText="username"/>
<asp:BoundField DataField ="password" HeaderText="password" />

</Columns>
</asp:GridView>


    </div>
    </form>
</body>
</html>

Aspx.cs Page 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace VP_Industries
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
        SqlCommand cmd;
        SqlDataAdapter da;
        DataTable dt;
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                BindGridviewData();
            }
        }
        protected void BindGridviewData()
        {
            da = new SqlDataAdapter("select * from login where id=1",con);
            dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                gvdata.DataSource = dt;
                gvdata.DataBind();
            }
            else
            {
                gvdata.DataSource = "";
                gvdata.DataBind();
            }
        }
    }
}