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

Thursday, 28 November 2013

How to create AutoCompleteTextBox in Windows Application

How to create AutoCompleteTextBox in Windows Application………………………..

Note: AutoCompleteTextBox means  it gives full hits of the coming text

//This query execute in Sql Server 2008 for create database and table…………..

create database Autocomplete
create table tbl_autocomplete(id int identity(1,1) primary key,name nvarchar(50) unique)

After execute this query We take one Windows Application as the picture is given below we create  a Windows Form just like the picture……………….


//This source code  for  Form1.cs……………………..

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.Data.SqlClient;

namespace AutoCompleteTextBox_Windows
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//call this method here
AutoComplete();
}

SqlConnection con = new SqlConnection("Data Source=KUSH-PC\\KUSH;Initial Catalog=Autocomplete;User ID=sa;Password=tiwari");
SqlCommand cmd;
//code for create method TextBox with AutoComplete ....................................
void AutoComplete()
{
textBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
AutoCompleteStringCollection col = new AutoCompleteStringCollection();
cmd = new SqlCommand("select * from tbl_autocomplete", con);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
//string s = "name";
string name = rdr.GetString(1);
col.Add(name);
}
con.Close();
textBox1.AutoCompleteCustomSource = col;

}

// code for when you insert any word
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter("select * from tbl_autocomplete where name like '" + textBox1.Text + "'", con);
da.Fill(dt);
dataGridView1.DataSource = dt;
}

}
}

 Result………………………………………..

Friday, 22 November 2013

How to send mail with attachment through Gmail in Asp.Net

How to send mail with attachment through Gmail in Asp.Net

Source Code for  SendingMail.aspx…………………………………..

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

<!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: 75%;
 }
</style>

<script type="text/javascript" language="javascript">
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div >

<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<table class="style1">
<tr><td colspan="2">
<center> <b><font color="red">How to send an email with attachment through gmail</font></b></center></td>
</tr>
<tr><td>Enter Your Name</td>
<td>
<asp:TextBox ID="txtUserName" runat="server" Width="445px"></asp:TextBox>
</td>
</tr>
<tr><td>Your Gmail Address</td>
<td>
<asp:TextBox ID="txtGmailAddress" runat="server" Width="445px"></asp:TextBox>
</td>
</tr><tr><td>Your Gmail Password</td>
<td>
<asp:TextBox ID="txtGmailPassword" runat="server" Width="445px"
 TextMode="Password"></asp:TextBox>
</td>
</tr><tr><td>Email To</td><td>
<asp:TextBox ID="txtEmaillTo" runat="server" Width="445px"></asp:TextBox>
</td>
</tr>
<tr><td>Subject</td>
<td>
<asp:TextBox ID="txtSubject" runat="server" Width="445px"></asp:TextBox>
</td>
</tr><tr><td>Attachment</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" multiple="true" />
</td>
</tr>
<tr><td>Message</td>
<td>
<asp:TextBox ID="txtMessageBody" runat="server" Height="176px"
TextMode="MultiLine" Width="445px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
<asp:Label ID="lblmessage" runat="server" Text="Label" Visible="False"></asp:Label>
</td>
</tr>
</table>

</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnSend"  />

</Triggers>
</asp:UpdatePanel>

<asp:Button ID="btnSend" runat="server" Text="Send Mail" Width="145px"
onclick="btnSend_Click" />
</div>

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

Source Code for  SendingMail.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.Net;
using System.Net.Mail;
using System.Drawing;

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

}
protected void btnSend_Click(object sender, EventArgs e)
{
MailMessage ml = new MailMessage();

ml.To.Add(txtEmaillTo.Text);

ml.From = new MailAddress(txtGmailAddress.Text.Trim(),txtUserName.Text.Trim());
ml.Subject = txtSubject.Text;
string Bd = txtMessageBody.Text;
ml.Body = Bd;

ml.IsBodyHtml = true;
if (FileUpload1.HasFile)
{
ml.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream,FileUpload1.FileName));
}

SmtpClient smtpcode = new SmtpClient();
smtpcode.Host = "smtp.gmail.com";
smtpcode.Port = 587;
smtpcode.UseDefaultCredentials = false;
smtpcode.Credentials = new   System.Net.NetworkCredential(txtGmailAddress.Text.Trim(), txtGmailPassword.Text.Trim());
smtpcode.EnableSsl = true;
lblmessage.Visible = true;
try
{
lblmessage.ForeColor = Color.Green;
lblmessage.Text = "Message send successfully";
smtpcode.Send(ml);

}
catch (Exception ex)
{
lblmessage.ForeColor = Color.Red;
lblmessage.Text =ex.Message;
}
}
}