This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Me And My Respected Teacher Mr Kamal Sheel Mishra

Mr. K.S. Mishra is HOD of Computer Science from SMS Varanasi where I have completed my MCA

Me And My Respected Teacher Mr Udayan Maiti

Mr. Udayan Maiti is a senior .Net Expert and has guided many professionals of multi national Companies(MNC)

Me And My Best Friend Mr Ravinder Goel

Mr. Ravinder Goel is a senior Software Engineer and now he is working Wipro Technology

Friday 31 August 2012

What is CSS,Type of Css,Inline,Internal,External Style Sheet

CSS (Cascading Style Sheets)


 What is CSS? 

CSS stands for cascading style sheets Styles define how to display HTML elements Styles are normally stored in Style Sheets Styles were added to HTML 4.0 to solve a problem External Style Sheets can save you a lot of work External Style Sheets are stored in CSS files Multiple style definitions will cascade into one.

                Style sheets are a very powerful tool for the Web site developer. They give you the chance to be completely consistent with the look and feel of your pages, while giving you much more control over the layout and design than straight HTML ever did.


Types of CSS: There are three type Style sheets

a.    Inline Styles
b.    Internal Style Sheet
c.    External Style Sheet

 Inline Styles: An inline style loses many of the advantages of style sheets by mixing content with presentation. Use this method sparingly, such as when a style is to be applied to a single occurrence of an element.
To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example shows how to change the color and the left margin of a paragraph:

For Example:

<p style="color: red; margin-left: 20px">
     This is a paragraph
    </p>

   Internal Style Sheet: An internal style sheet should be used when a single document has a    unique style. You define internal styles in the head section by using the <style> tag, like this:

  <head>
  <style type="text/css">
   hr {color: green}
   p {margin-left: 20px}
   body {background-image: url ("images/kushtiwari.gif")}
   </style>
  </head>

The browser will now read the style definitions, and format the document according to it.



External Style Sheet:  An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link > tag. The <link > tag goes inside the head section:

<head >
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>


Other CSS Questions



Question: Style Sheets Can Save a Lot of Work

Answer:
 Enforcing data integrity ensures the quality of the data in the database. For example, if an employee is entered with an employee_id value of 123, the database should not allow another employee to have an ID with the same value. If you have an employee_rating column intended to have values ranging from 1 to 5, the database should not accept a value of 6. If the table has a dept_id column that stores the department number for the employee, the database should allow only values that are valid for the department numbers in the company. Two important steps in planning tables are to identify valid values for a column and to decide how to enforce the integrity of the data in the column. Data integrity falls into these categories.

Question: When do you use CSS dimension?

Answer: The CSS dimension properties allow you to control the height and width of an element. It also allows you to increase the space between two lines.

Question: CSS purpose and Used for?

Answer:
CSS is a language, separate from HTML or XHTML CSS used to specify the layout or formatting properties of HTML elements From a single CSS file you can control an entire sites:
font type ,font and element color ,padding ,margins ,and element positioning CSS allows developers to separate style (look, appearance, colors, fonts, layout) from the pages structure.


Question: What is the CSS Web Template?

Answer:
"CSS Web Template"  is a website design created using Cascading Style Sheets (CSS) technology. Cascading style sheets provide web developers an easy way to format and to style web pages. CSS will be used even more because it is seen the same way by all browsers, making it the best option during the browser wars.


                                                                                                                           Next Topic with CSS

Tuesday 21 August 2012

File Handling in C# ..NET ( How to Save Image Binary Format in Database Table and retrieve it..)


Frist we  create table TableImage in database test and image is saved  in table binary  format………………………………………

use test
Create table TableImage (Id int primary key,Name nvarchar(50),UserImage varbinary(max))



How  to  save  image  in table in Binary Format and how to retrive it in Windows Application
(C# .NET)………………..


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlClient;
namespace FileHandlingExp
{
    public partial class StoreImageInDataBase : Form
    {
        public StoreImageInDataBase()
        {
            InitializeComponent();
        }

        private void StoreImageInDataBase_Load(object sender, EventArgs e)
        {

        }

        object objimage;
        SqlDataReader dr;

//Code  for  select image  from  any Drive……………………………………………

         private void btnSelectImage_Click(object sender, EventArgs e)
            {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                txtimagesource.Text = openFileDialog1.FileName;
            }
        }

//Code  for  save image in table  in binary format

        private void btnSaveImage_Click(object sender, EventArgs e)
        {
            FileStream fs = new FileStream(txtimagesource.Text, FileMode.Open);
            byte[] data = new byte[fs.Length];
            fs.Read(data, 0, Convert.ToInt32(fs.Length));
            SqlConnection con = new SqlConnection("Data Source=KUSH-PC;Initial Catalog=test;Integrated Security=True");
            SqlCommand com = new SqlCommand("insert into TableImage(Id,Name,UserImage) values(@id,@name,@image)", con);
            com.Parameters.AddWithValue("@id",Convert.ToInt32(txtid.Text));
            com.Parameters.AddWithValue("@name", txtname.Text);
            com.Parameters.AddWithValue("@image", data);
            con.Open();
            com.ExecuteNonQuery();
            con.Close();
            MessageBox.Show("Image Added");
        }


//Code  for  show image(binary format) in PictureBox  from table  …………………………

        private void btnLoadImage_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("Data Source=KUSH-PC;Initial Catalog=test;Integrated Security=True");
            SqlCommand com = new SqlCommand("select Id,Name,UserImage from TableImage where Id=@id", con);
            com.Parameters.AddWithValue("@id", Convert.ToInt32(txtid.Text));
          
            con.Open();
            dr = com.ExecuteReader();
            if (dr.HasRows)
            {
                dr.Read();
                txtname.Text= ""+dr["Name"];
                objimage = dr["UserImage"];

                }

          //objimage = com.ExecuteScalar();
            byte[] data;
            data = (byte[])objimage;
            MemoryStream ms = new MemoryStream(data);
            pictureBox1.Image = Image.FromStream(ms);
            con.Close();
        }

//Code for  go to next page…………………………………………

        private void btnNextPage_Click(object sender, EventArgs e)
        {
            CopyFile cf = new CopyFile();
            cf.Show();
        }
      }
}


After retrieve  image  from table image is  stored  in binary format  and after retrieve  image show  in PictureBox Control in Windows Application in C# .NET






How  to  copy  image  from  another  location from  computer drive and paste  in other drive in computer in Windows Application in C# .NET


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace FileHandlingExp
{
    public partial class CopyFile : Form
    {
        public CopyFile()
        {
            InitializeComponent();
        }

 
       // Code for next page
        private void btnNext_Click(object sender, EventArgs e)
        {
            StoreImageInDataBase si = new StoreImageInDataBase();
            si.Show();
        }

 // Code for  how  to select image  from Computer drive …………..

        private void btnSelectSource_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                txtsourceaddress.Text = openFileDialog1.FileName;
            }
        }

// Code for  copy  image  where is  paste in  Computer drive …………..

        private void btnLocateSource_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                txtdestinationaddress.Text = saveFileDialog1.FileName;
            }

          
        }
 // Code for  how  to save image  ……………………………………

        private void btnCopyPaste_Click(object sender, EventArgs e)
        {
            FileStream fssource = new FileStream(txtsourceaddress.Text, FileMode.Open);
            FileStream fsdest = new FileStream(txtdestinationaddress.Text, FileMode.Create);
            while (true)
            {
                int i;
                i = fssource.ReadByte();
                if (i == -1)
                    break;
                fsdest.WriteByte(Convert.ToByte(i));
            }
            fsdest.Close();
            MessageBox.Show("Image copy in Location");
          
        }
        
    }

}






Sunday 19 August 2012

How to Use FileUpload in Asp.Net ,How to Save Image ,Picture in Website Folder


First we  craete  a  table UserImage using database test

use test
create  table UserImage(SrNo int  primary key,Name nvarchar(50),UserImg nvarchar(max))

After than we  create  a Web from  like  this and  take  a Folder Image  in our  WebSite  for  saving  image  which are  upload  by  user………..




This  is  source code of 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></title>
    <style type="text/css">
        .style1 {
            width: 100%;
        }
        .style2
        {
            width: 351px;
        }
    </style>
</head>
<body>
   
    <form id="form1" runat="server">
    <div>
    <table class="style1">
        <tr>
            <td colspan="3"><center><asp:Label ID="Label1" runat="server" Text="Save Image in Image folder and Database" Font-Bold="true"></asp:Label></center>
               
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="SrNo" runat="server" Text="SrNo"></asp:Label>
            </td>
            <td class="style2">
                <asp:TextBox ID="txtsrno" runat="server"></asp:TextBox>
            </td>
            <td rowspan="5">
                <asp:Image ID="Image1" runat="server" Height="91px" Width="99px" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label4" runat="server" Text="Name"></asp:Label>
            </td>
            <td class="style2">
                <asp:TextBox ID="txtname" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label5" runat="server" Text="Image"></asp:Label>
            </td>
            <td class="style2">
                <asp:FileUpload ID="FileUpload1" runat="server" />
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td class="style2">

                <asp:Button ID="BSave" runat="server" onclick="BSave_Click" Text="Save" />
            <asp:Button ID="BSelect" runat="server" onclick="BSelect_Click" Text="Select" />
                <asp:Button ID="BDelete" runat="server" onclick="BDelete_Click" Text="Delete" />
&nbsp;<asp:Button ID="BUpdate" runat="server" onclick="BUpdate_Click" Text="Update" />
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td class="style2">
                <asp:Label ID="Message" runat="server" Text="Label" Visible="False"></asp:Label>
            </td>
        </tr>
    </table>
    </div>
    </form>
</body>
</html>



We create  Connection  global  for  Website  in web.config …………………

<configuration>
  <connectionStrings>
    <add name="kush" connectionString="Data Source=KUSH-PC; Initial Catalog=test;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
  </system.web>
</configuration>


This  code  for  Default.aspx.cs…………………………………………..


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

// using this  namespace  for   DirectoryInfo and FileInfo

using System.IO;

public partial class _Default : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
       
        con = new SqlConnection(ConfigurationManager.ConnectionStrings["kush"].ConnectionString);
    }

    SqlConnection con;
    SqlCommand cmd;
    SqlDataReader dr;

    //this  code  for  Saving image  in Database  and  Image Folder which are exist  in      Website...............

    protected void BSave_Click(object sender, EventArgs e)

    {
       
        con.Open();
        cmd = new SqlCommand("insert into UserImage (SrNo,Name,UserImg) values (@SrNo,@Name,@UserImg)", con);
        cmd.Parameters.AddWithValue("@SrNo", Convert.ToInt32(txtsrno.Text));
        cmd.Parameters.AddWithValue("@Name", txtname.Text);
        cmd.Parameters.AddWithValue("@UserImg", FileUpload1.FileName);
        FileUpload1.SaveAs(Server.MapPath("~/Image/") + FileUpload1.FileName);
        cmd.ExecuteNonQuery();
         Message.Visible=true;
        Message.Text = "Add Successfully ";
        con.Close();
        txtname.Text = "";

 }

    //this  code  for  retrive image  from Database  and  Image Folder which are exist  in     Website...............

    protected void BSelect_Click(object sender, EventArgs e)
    {
       
        con.Open();
        cmd = new SqlCommand("select * from UserImage where SrNo=@SrNo", con);
        cmd.Parameters.AddWithValue("@SrNo", Convert.ToInt32(txtsrno.Text));
         dr=cmd.ExecuteReader();
         if (dr.Read())
         {
             txtname.Text = dr["Name"].ToString();
             Image1.ImageUrl = "~/Image/" + dr["UserImg"].ToString();

         }
    
        con.Close();
   
    }



    //this  code  for  delete image  from  Database  and  Image Folder which are exist  in  Website...............

    protected void BDelete_Click(object sender, EventArgs e)

    {

        DirectoryInfo dd = new DirectoryInfo(Server.MapPath("~/Image"));
        foreach (FileInfo ff in dd.GetFiles())
        {
            if (ff.Name == Path.GetFileName(Image1.ImageUrl))
                ff.Delete();
        }

         con.Open();
         cmd = new SqlCommand("delete from UserImage where SrNo=@SrNo", con);
         cmd.Parameters.AddWithValue("@SrNo", Convert.ToInt32(txtsrno.Text));
         cmd.ExecuteNonQuery();
         con.Close();
         txtname.Text = "";
         Message.Visible=true;
         Message.Text="Delete Successfully Image "+"For SrNo"+"-"+txtsrno.Text+"";
}

    //this  code  for  Update  image  in Database  and  Image Folder and  old  image  deleted  from Image Folder

    protected void BUpdate_Click(object sender, EventArgs e)
    {
        try
        {

            DirectoryInfo dd = new DirectoryInfo(Server.MapPath("~/Image"));
            foreach (FileInfo ff in dd.GetFiles())
            {
                if (ff.Name == Path.GetFileName(Image1.ImageUrl))
                    ff.Delete();
            }

            con.Open();
            cmd = new SqlCommand("update  UserImage set Name=@Name, UserImg=@UserImg  where SrNo=@SrNo", con);
            cmd.Parameters.AddWithValue("@SrNo", Convert.ToInt32(txtsrno.Text));
            cmd.Parameters.AddWithValue("@Name", txtname.Text);
            if (FileUpload1.HasFile)
            {
                cmd.Parameters.AddWithValue("@UserImg", FileUpload1.FileName);
            }
            else
            {
                cmd.Parameters.AddWithValue("@UserImg", Image1.ImageUrl);
            }

            FileUpload1.SaveAs(Server.MapPath("~/Image/") + FileUpload1.FileName);
            cmd.ExecuteNonQuery();
            con.Close();
            txtname.Text = "";
            Message.Visible = true;
            Message.Text = "update Successfully Image " + "For SrNo" + "-" + txtsrno.Text + "";
        }
        catch (Exception ex)
        {
            Message.Visible = true;
            Message.Text = ex.Message;
        }
       
    }
}




             Means  image will be  save Image  Folder  and  table in Database……………………..