Monday, 19 October 2015

Decrypt Text

   private string Decrypt(string cipherText)  //For Decrypt
    {
        string EncryptionKey = "MAKV2SPBNI99212";
        byte[] cipherBytes = Convert.FromBase64String(cipherText);
        using (Aes encryptor = Aes.Create())
        {
            Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
            encryptor.Key = pdb.GetBytes(32);
            encryptor.IV = pdb.GetBytes(16);
            using (MemoryStream ms = new MemoryStream())
            {
                using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
                {
                    cs.Write(cipherBytes, 0, cipherBytes.Length);
                    cs.Close();
                }
                cipherText = Encoding.Unicode.GetString(ms.ToArray());
            }
        }
        return cipherText;
    }


    private void passcheck()
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from ustable where uid='" + Encrypt(TextBox1.Text) + "'", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable(); da.Fill(dt);
        con.Close();
        if (TextBox1.Text == Decrypt(dt.Rows[0]["uid"].ToString()))
        {
            Response.Write("password checked");
        }
        else
        {
            Response.Write("Not Valid");
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        passcheck();
    }

EncryptText

Encrypt Text


  private string Encrypt(string clearText)         // Functon for plane text to encrypt text
    {
        string EncryptionKey = "MAKV2SPBNI99212";
        byte[] clearBytes = Encoding.Unicode.GetBytes(clearText);
        using (Aes encryptor = Aes.Create())
        {
            Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
            encryptor.Key = pdb.GetBytes(32);
            encryptor.IV = pdb.GetBytes(16);
            using (MemoryStream ms = new MemoryStream())
            {
                using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
                {
                    cs.Write(clearBytes, 0, clearBytes.Length);
                    cs.Close();
                }
                clearText = Convert.ToBase64String(ms.ToArray());
            }
        }
        return clearText;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string uid=Encrypt(TextBox1.Text);
        string pwd=Encrypt(TextBox2.Text);
        con.Open();
        SqlCommand cmd = new SqlCommand("insert into ustable (uid,pass) values ('" + uid + "','" + pwd + "')",con);
       
        int i = cmd.ExecuteNonQuery();
        con.Close();
        if (i > 0)
        {
            Response.Write("Saved");
        }
        else
        {
            Response.Write("Eroor....");
        }
    }

Wednesday, 7 October 2015

sp_executesql in procedure with separate query,parameter

sp_executesql in procedure with separate query,parameter

CREATE PROCEDURE Myproc-- 'pabitra','@parm1OUT',''
    @parm varchar(10),
    @parm1OUT varchar(30) OUTPUT,
    @parm2OUT varchar(30) OUTPUT
    AS
      SELECT @parm1OUT='parm 1' + @parm
     SELECT @parm2OUT='parm 2' + @parm
GO
DECLARE @SQLString NVARCHAR(500)
DECLARE @ParmDefinition NVARCHAR(500)
DECLARE @parmIN VARCHAR(10)
DECLARE @parmRET1 VARCHAR(30)
DECLARE @parmRET2 VARCHAR(30)
SET @parmIN=' returned'
SET @SQLString=N'EXEC Myproc @parm,
                             @parm1OUT OUTPUT, @parm2OUT OUTPUT'
SET @ParmDefinition=N'@parm varchar(10),
                      @parm1OUT varchar(30) OUTPUT,
                      @parm2OUT varchar(30) OUTPUT'

EXECUTE sp_executesql
    @SQLString,
    @ParmDefinition,
    @parm=@parmIN,
    @parm1OUT=@parmRET1 OUTPUT,@parm2OUT=@parmRET2 OUTPUT

SELECT @parmRET1 AS "parameter 1", @parmRET2 AS "parameter 2"
go
drop procedure Myproc

Data Annotations in entity framework

SQL Setting Default value of Date and time in Table

SQL Setting Default value of Date and time in Table

create table Mst_Category
(
Cat_Auto bigint not null primary key identity(1,1),
Cat_Id varchar(20) not null,
Cat_Name varchar(100),
userId varchar(20),
dflag int,
Sys_Date datetime default getdate(),
sys_Time  time default CONVERT(time, GETDATE())
)


create table Mst_Category
(
Cat_Auto bigint not null primary key identity(1,1),
Cat_Id varchar(20) not null,
Cat_Name varchar(100),
userId varchar(20),
dflag int,
Sys_Date datetime default getdate(),
sys_Time  varchar(20) default RIGHT(CONVERT(CHAR(20), GETDATE(), 22), 11)--For AM and PM
)

Sql Trigger Insert,Update,Delete

Sql Trigger Insert,Update,Delete

create table tblMain
  (
   Id int not null Primary Key identity(1,1) ,
   Name varchar(100),
   dflag int,
   userId varchar(20)
    )


create table tblMain_Image
  (
  AutoId bigint not null Primary key identity(1,1),
    Id int  not null,
    Name varchar(100),
    userId varchar(20),
    dflag int,
Sys_Date datetime default getdate(),
sys_Time  varchar(20) default RIGHT(CONVERT(CHAR(20), GETDATE(), 22), 11)--For AM and PM
    )
----------------------------------INSERT----------------------------  
create trigger [dbo].[Triger_Insert_tblMain] ON  [dbo].[tblMain] FOR INSERT
AS
BEGIN
     set nocount on
    insert into [dbo].[tblMain_Image]
           (Id,Name,userId,dflag)
    SELECT Id,Name,userId,0
    FROM inserted;
 
END
----------------------------------INSERT-----------------------------------


----------------------------------UPDATE---------------------------------
create trigger [dbo].[Triger_Update_tblMain] ON  [dbo].[tblMain] FOR UPDATE
AS
BEGIN
    set nocount on
    insert into [dbo].[tblMain_Image]
           (Id,Name,userId,dflag)
    SELECT Id,Name,userId,1
    FROM inserted;
 
END
---------------------------------UPDATE---------------------------------


---------------------------DELETE------------------------------------
create  trigger Triger_Delete_tblMain on  [dbo].[tblMain]
FOR DELETE
AS
begin
 set nocount on
     insert into [dbo].[tblMain_Image]
           (Id,Name,userId,dflag)
    SELECT Id,Name,userId,2
    FROM deleted;
end
---------------------------DELETE------------------------------------

c# Page.ClientScript.RegisterStartupScript

c# Page.ClientScript.RegisterStartupScript

 Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('Hello Mr Pabitra Now your eligible for join in microsoft');window.location.href=('Thanku.aspx');</script>");

custom message in asp.nt

custom message in asp.nt

<%@ 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:Button ID="btnClick" runat="server" Text="Click Me" OnClick="btnClick_Click" />
    </div>
    </form>
</body>
</html>
---------------------
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 btnClick_Click(object sender, EventArgs e)
    {
        CustomPopup.Show(this.Page, "Hello Pabitra Microsoft");
    }
 
 
}
public static class CustomPopup
{
    public static void Show(this Page Page, String Message)
    {
        Page.ClientScript.RegisterStartupScript(Page.GetType(),"MessageBox","<script language='javascript'>alert('" + Message + "');</script>");
    }
}

C#- different type of alert message in code behind

C#- different type of alert message in code behind

 string Message = "Pabitra you as Microsoft Employee !";
         ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Pabitra you as Microsoft Employee !');", true);
         ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + Message + "');", true);

         ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Pabitra you as Microsoft Employee !');", true);
         ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + Message + "');", true);

         Response.Write(@"<script language='javascript'>alert('Pabitra you as Microsoft Employee ! ')</script>");
         Response.Write(@"<script language='javascript'>alert('"+Message+"')</script>");

         Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "<script language='javascript'>alert('Pabitra you as Microsoft Employee !');</script>");
         Page.ClientScript.RegisterStartupScript(Page.GetType(),"MessageBox","<script language='javascript'>alert('" + Message + "');</script>");

         ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Pabitra you as Microsoft Employee !')", true);
         ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('" + Message + "')", true);
        ////////////////
         ClientScript.RegisterClientScriptBlock(GetType(), "Email", "GetEmail();", true);
        //In Html Page
        <head>
        <script type="text/javascript" language="javascript">
         function GetEmail() {
             alert('hi');
         }
        </script>
    </head>
    ///////////////////////////

c# google plus integration in website

c# google plus integration in website

Follw the sample
https://developers.google.com/+/web/samples/csharp

Or Follow

http://www.c-sharpcorner.com/UploadFile/vdtrip/google-plus-authentication-in-Asp-Net-and-C-Sharp/

get ip address in c#

 //using System.Net;
        string hostName = Dns.GetHostName(); // Retrive the Name of HOST  
        string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString();
        Response.Write("My IP Address is :" + myIP); 

Switch Case In ASp.net With Examples By Pabitra

Switch Case In ASp.net With Examples By Pabitra

 Switch Case In ASp.net For Clear Method
 ------------------------------------------------------------------
 private void DesableEnableClear(string Status)
    {
  TextBox[] arr = { txtHeltID, txtHelthType };
   switch (Status)
   {
    case "D":
           foreach (TextBox txt in arr)
           {
            txt.Enabled = false;
           }
           txtHeltID.Text = "";
           break;        
    case "E":
            foreach (TextBox txt in arr)
            {
                txt.Enabled = true;
            }
            txtHeltID.Text = LoadMaxID();
            break;
    case "C":
           foreach (TextBox txt in arr)
            { txt.Text = ""; }
            btnSave.Enabled = true;
            txtHeltID.Text = LoadMaxID();
            break;
    case "GL":
            btnSave.Enabled = true;          
            btnDelete.Enabled = false;
            btnUpdate.Enabled = false;
            panelg.Visible = true;
            break;
    case "GR":
            btnSave.Enabled = false;
            btnDelete.Enabled = true;
            btnUpdate.Enabled = true;
            panelg.Visible = false;
            break;
       case "U":
           btnSave.Enabled = true;         
            btnDelete.Enabled = false;
            btnUpdate.Enabled = false;
            panelg.Visible = false;
            break;
      case "SD":
            lblSearch.Visible = false;
            txtSearch.Visible = false;
            break;
      case "SE":
            lblSearch.Visible = true;
             txtSearch.Visible = true;
            break;
      default :
           // Response.Write("Hello");
            break;
        } ////

how to change server side div background images

how to change server side div background images

how to change server side div background images
any one can help me....
my code is ..
 <div id="divID" runat="server" > </div>

 divID.Style["background-image"] = Page.ResolveUrl("~/body/backShadow.png");

Create a Full Database Backup In SQL Server

Create a Full Database Backup In SQL Server



BACKUP DATABASE DataBaseName TO DISK = 'D:\BackupName.bak'
Example
DataBase name:DbPabitra
BACKUP DATABASE DbPabitra TO DISK = 'D:\DataBaseBacup.bak'
For More Informatation
http://pabitramicrosoftresearch.blogspot.in/

DDL TRIGGER FOR ALL DATABASE CREATE,ALTER,DELETE TABLE IN SQLSERVER

---For All Server(DataBase)
ALTER trigger NoTable
on all server
for CREATE_TABLE,ALTER_TABLE,DROP_TABLE
AS BEGIN
PRINT 'NO NEW TABLE PLEASE'
ROLLBACK
END

inserted trigger in sql server

inserted trigger in sql server


CREATE TABLE [dbo].[tblTRIGGERMAST1](
[ID] [varchar](10) NOT NULL PRIMARY KEY,
[NAME] [varchar](20) NULL,
[PHONE] [int] NULL
)

CREATE TABLE [dbo].[tblTRIGGER2](
[ID] [int] IDENTITY(1001,1) PRIMARY KEY NOT NULL,
[IDMAST] [varchar](10) NULL,
[PHONE] [int] NULL,
[DATE] [datetime] NULL
)
CREATE  TRIGGER Triger_On_tblTRIGGERMAST1
ON  tblTRIGGERMAST1
AFTER INSERT
AS
BEGIN

SET NOCOUNT ON;
declare @ID int
declare @Phone int
declare @Result varchar(100)
select @ID=ID from inserted
select @Phone =PHONE from inserted
INSERT INTO tblTRIGGER2(IDMAST,PHONE)VALUES(@ID,@Phone)
set @Result=convert(varchar,'The Inserted Values Are Inserted in Table tblTRIGGER2:ID IS:  ')
+convert(varchar,@ID)+convert(varchar,' pHONE nO  Is: ')+convert(varchar,@Phone)
Print @Result

END
insert into tblTRIGGERMAST1(ID,NAME,PHONE)values(1004,'PABITRA BEHERA',828989)

-------------
---THE RESULT WILL BE
The Inserted Values Are Insert1004 pHONE nO  Is: 828989

(1 row(s) affected)

sql server restore database query

sql server restore database query

RESTORE DATABASE PabitraDemoDb

FROM DISK='d:\PabitraDemoDb.bak'

Disable Right Click of Page in c#

Disable Right Click of Page in c#

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Sample to Disable Right Click of Page</title>
<script language="JavaScript" type="text/javascript">
    //Message to display whenever right click on website
    var message = "Sorry, Right Click have been disabled.";
    function click(e) {
        if (document.all) {
            if (event.button == 2 || event.button == 3) {
                alert(message);
                return false;
            }
        }
        else {
            if (e.button == 2 || e.button == 3) {
                e.preventDefault();
                e.stopPropagation();
                alert(message);
                return false;
            }
        }
    }
    if (document.all) {
        document.onmousedown = click;
    }
    else {
        document.onclick = click;
    }
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
from Suresh
-----

sql alter drop rename column in the table

sql alter drop rename column in the table

To add a column in a table, use the following syntax:
------------------------------
ALTER TABLE table_name
ADD column_name datatype

-----------------------------
To delete a column in a table, use the following syntax (notice that some database systems don't
allow deleting a column):
--------------------------------------
ALTER TABLE table_name
DROP COLUMN column_name
-----------------------------


To change the data type of a column in a table, use the following syntax:
--------------------------------------------
ALTER TABLE table_name
ALTER COLUMN column_name datatype


----------------------------------
To rename Column Name
-------------------------
EXEC sp_RENAME 'table_name.old_name', 'new_name', 'COLUMN'

Key Down Events and Key press Events

Key Down Events and Key press Events

Key Down Events
-----------------


<script type="text/javascript">
        $(document).ready(function () {
            $("#<%= txtcontactno.ClientID%>").keydown(function (e) {
                if (e.shiftKey)
                    e.preventDefault();
                else {
                    var nKeyCode = e.keyCode;
                    //Ignore Backspace and Tab keys      
                    if (nKeyCode == 8 || nKeyCode == 9)
                        return;
                    if (nKeyCode < 95) {
                        if (nKeyCode < 48 || nKeyCode > 57)
                            e.preventDefault();
                    }
                    else {
                        if (nKeyCode < 96 || nKeyCode > 105)
                            e.preventDefault();
                    }
                }
            });
        });
    </script>
Key press Events
-----------------
 <script type="text/javascript">

        $(document).ready(function () {
            //called when key is pressed in textbox
            $('#<%=txtcontactno.ClientID%>').keypress(function (e) {
                alert('hello');
                //if the letter is not digit then display error and don't type anything
                if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
                    //display error message
                    //  alert('Please Enter ');
                    //  $("#errmsg").html("Digits Only").show().fadeOut("slow");
                    return false;
                }
            });
        });

    </script>

For Clear Session

For Clear Session

 Session.Abandon();
        Session.RemoveAll(); Session.Clear();

Concate Sql Query in c#

Concate Sql Query in c#

  The  Below query is concate in c#
When a long query we write we impliments this
Solution
-----------
 protected void Button1_Click(object sender, EventArgs e)
    {

        string Name = "Pabitra";
        // string Query = "insert into tblEmployee ( id, name ) values( " + 4 + ",'" + Name + "' )";
        string Query = "insert into tblEmployee " +
            " (        " +
            " id,      " +
            " name     " +
            " )        " +

            " values(  " +
            "" + 4 + "," +
            "'" + Name + "' " +
            " )";
        Response.Write(Query);
    }

Date Time Picker in Jquery

Date Time Picker in Jquery

  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#<%=txtFromdate.ClientID%>').datepicker({ dateFormat: "dd/mm/yy" }).val()
            $('#<%=txtTodate.ClientID%>').datepicker({ dateFormat: "dd/mm/yy" }).val()
        });
      
   </script>


<div>

<asp:TextBox ID="txtFromdate" Width="35%" runat="server" placeholder="Select Date" ToolTip="From Date" AutoCompleteType="Disabled" TabIndex="1"></asp:TextBox>

<br/>
<asp:TextBox ID="txtTodate" Width="35%" runat="server" placeholder="Select Date" ToolTip="From Date" AutoCompleteType="Disabled" TabIndex="1"></asp:TextBox>



</div>

Get USD to INR exchange rate dynamically in C#

Get USD to INR exchange rate dynamically in C# 

using System.IO;
using System.Net;
using System.Xml;
----------------------

 private void button2_Click(object sender, EventArgs e)
        {
            WebRequest webrequest = WebRequest.Create("http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=INR");
            HttpWebResponse response = (HttpWebResponse)webrequest.GetResponse();
            Stream dataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(dataStream);
            string responseFromServer = reader.ReadToEnd();
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseFromServer);
            string value = doc.InnerText;

            MessageBox.Show(value);
            reader.Close();
            dataStream.Close();
            response.Close();


        }

Repeater Control In Asp.net

Repeater Control In Asp.net

USE [DBPABITRA]
GO

/****** Object:  Table [dbo].[tbexecutive]    Script Date: 01/06/2015 17:47:58 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[tbexecutive](
[id] [varchar](10) NULL,
[workername] [varchar](50) NULL,
[currentadd] [varchar](50) NULL
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO


-------------------------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.Configuration;
using System.Data.SqlClient;
public partial class RepeatearControl : System.Web.UI.Page
{  
    SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=mypass;database=MyDB");
    protected void Page_Load(object sender, EventArgs e)
    {

        if (con.State == ConnectionState.Closed)
        {

            con.Open();

        }

        if (Page.IsPostBack == false)
        {

            Show_Data();

        }

    }

    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {

        if (e.CommandName == "edit")
        {

            ((Label)e.Item.FindControl("Label1")).Visible = false;

            ((Label)e.Item.FindControl("Label2")).Visible = false;

            ((TextBox)e.Item.FindControl("Textbox1")).Visible = true;

            ((TextBox)e.Item.FindControl("Textbox2")).Visible = true;

            ((LinkButton)e.Item.FindControl("LinkEdit")).Visible = false;

            ((LinkButton)e.Item.FindControl("LinkDelete")).Visible = false;

            ((LinkButton)e.Item.FindControl("LinkUpdate")).Visible = true;

            ((LinkButton)e.Item.FindControl("Linkcancel")).Visible = true;

        } if (e.CommandName == "delete")
        {

            SqlCommand cmd = new SqlCommand("delete from tbexecutive where id=@id", con);

            cmd.Parameters.AddWithValue("@id", e.CommandArgument);

            cmd.ExecuteNonQuery();

            cmd.Dispose();

            Page.ClientScript.RegisterStartupScript(this.GetType(), "ch", "");

            Show_Data();

        }

        if (e.CommandName == "update")
        {

            string str1 = ((TextBox)e.Item.FindControl("TextBox1")).Text;

            string str2 = ((TextBox)e.Item.FindControl("TextBox2")).Text;

            SqlDataAdapter adp = new SqlDataAdapter("update tbexecutive set workername=@workername, currentadd=@add where id=@id", con);

            adp.SelectCommand.Parameters.AddWithValue("@workername", str1);

            adp.SelectCommand.Parameters.AddWithValue("@add", str2);

            adp.SelectCommand.Parameters.AddWithValue("@id", e.CommandArgument);

            DataSet ds = new DataSet();

            adp.Fill(ds);

            Show_Data();

            Page.ClientScript.RegisterStartupScript(this.GetType(), "ch", "");

        } if (e.CommandName == "cancel")
        {

            ((Label)e.Item.FindControl("Label1")).Visible = true;

            ((Label)e.Item.FindControl("Label2")).Visible = true;

            ((TextBox)e.Item.FindControl("TextBox1")).Visible = false;

            ((TextBox)e.Item.FindControl("TextBox2")).Visible = false;

            ((LinkButton)e.Item.FindControl("LinkEdit")).Visible = true;

            ((LinkButton)e.Item.FindControl("LinkDelete")).Visible = true;

            ((LinkButton)e.Item.FindControl("LinkUpdate")).Visible = false;

            ((LinkButton)e.Item.FindControl("Linkcancel")).Visible = false;

        }



    }

    public void Show_Data()
    {

        SqlDataAdapter adp = new SqlDataAdapter("select * from tbexecutive ORDER BY workername ASC", con);

        DataSet ds = new DataSet();

        adp.Fill(ds);

        Repeater1.DataSource = ds;

        Repeater1.DataBind();

    }

}

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


<!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="form2" runat="server">
    <div>
 
        <asp:Repeater ID="Repeater1" runat="server"
            onitemcommand="Repeater1_ItemCommand">
            <HeaderTemplate>
         

          <table width="350"><tr
bgcolor="#FF6600"><td>Name</td><td>Address</td><td>Action</td></tr></HeaderTemplate>

           <ItemTemplate><tr><td> <asp:Label
ID="Label1" runat="server" Text='<%#Eval("workername")
%>'></asp:Label>

      <asp:TextBox ID="TextBox1" runat="server"
Text='<%#Eval("workername") %>'
Visible="false"></asp:TextBox>
        </td>
        <td>
        <asp:Label ID="Label2" runat="server" Text='<%#Eval("currentadd") %>'></asp:Label>

      <asp:TextBox ID="TextBox2" runat="server"
Text='<%#Eval("currentadd") %>'
Visible="false"></asp:TextBox>
        </td>
         <td>

      <asp:LinkButton ID="LinkEdit" runat="server"
CommandArgument='<%#Eval("id") %>'
CommandName="edit">Edit</asp:LinkButton>

          <asp:LinkButton ID="LinkDelete" runat="server"
CommandArgument='<%#Eval("id") %>'
CommandName="delete">Delete</asp:LinkButton>

          <asp:LinkButton ID="LinkUpdate" runat="server"
CommandArgument='<%#Eval("id") %>' CommandName="update"
Visible="false">Update</asp:LinkButton>

          <asp:LinkButton ID="Linkcancel" runat="server"
CommandArgument='<%#Eval("id") %>' CommandName="cancel"
Visible="false">Cancel</asp:LinkButton>
            </td>
        </tr>
         
     
     
        </ItemTemplate>
        </asp:Repeater>
 
    </div>
    </form>
</body>
</html>
---------------------------

Send Mail in c# through gmail

using System.Configuration;
using System.Net;
using System.IO;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;
----------------
 protected void btnSendMail1_Click(object sender, EventArgs e)
      {
          string ToWhomYouMail = "pabitrakiims@gmail.com";//Send to mail
          string Subject = "Test Mail";
          string mailbody = "<html><body><div>Dear Sir ,Good Morning</div></body></html>";
          bool m = send_mail(ToWhomYouMail, Subject, mailbody);
          if (m)
          {
              ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('Mail Send Sucessfully !');", true);
          }
          else
          {
              ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('An Error Occurs !');", true);
          }
      }



 public bool send_mail(string ToMail,string subject,string body)
       {
           bool k = false;
           try
           {
               MailMessage msg = new MailMessage("pabitra.best28@gmail.com", ToMail);
               msg.To.Add(ToMail);
            msg.Subject = subject;
            msg.Body = body;
            msg.IsBodyHtml = true;
            AlternateView view;
            SmtpClient client;
            msg.IsBodyHtml = true;
            client = new SmtpClient();
            client.Host = "smtp.gmail.com";
            client.Port = 587;
            client.Credentials = new System.Net.NetworkCredential("pabitra.best28@gmail.com", "password@123");
            client.EnableSsl = true; //Gmail works on Server Secured Layer
            client.Send(msg);
            k = true;
            //return k;
        }catch(Exception ex)
        {
            k = false;
        }
        return k;
     
    }

Google Map Current Loacatation

Copy the Code And Past in Aspx Page and Run You Find the Current Locatation
------------------------------------------------------------------


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

<!DOCTYPE html>
<html>
    <head>
        <script src="http://maps.google.com/maps/api/js?sensor=false">
        </script>
        <script>
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(showCurrentLocation);
            }
            else {
                alert("Geolocation API not supported.");
            }

            function showCurrentLocation(position) {
                var latitude = position.coords.latitude;
                var longitude = position.coords.longitude;
                var coords = new google.maps.LatLng(latitude, longitude);

                var mapOptions = {
                    zoom: 15,
                    center: coords,
                    mapTypeControl: true,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };

                //create the map, and place it in the HTML map div
                map = new google.maps.Map(
                document.getElementById("mapPlaceholder"), mapOptions
                );

                //place the initial marker
                var marker = new google.maps.Marker({
                    position: coords,
                    map: map,
                    title: "Current location!"
                });
            }
        </script>
    </head>
    <style>
    #mapPlaceholder {
        height: 400px;
        width: 700px;
    </style>
    <body>
        <div>
        <h2>HTML5 Show Location on GoogleMap Sample</h2>
        <div id="mapPlaceholder"></div>
        </div>
    </body>
</html>