Create Free Blog | Random Blog »   Report Abuse | Login   

 
 

Best HTML codes ;)

January 11th, 2010

Creating Marquee in HTML

How To:

First Open your notepad and type this code and then save this with any name but the extesion should be = .htm or .html

Code for Marquee

 
 <HTML>
<BODY BGCOLOR="GREEN">
<MARQUEE bgcolor="#CCCCCC" loop="-1" scrollamount="2" width="100%">NIKHIL KUMAR JAUHARI</MARQUEE>
</BODY>
</HTML>
Create a form in HTML

 <HTML>
<TITLE> MY WEB PAGE
</TITLE>
<BODY ALIGN="CENTER">
<FORM ALIGN="CENTER">
USERNAME <INPUT TYPE="TEXT" NAME="TEXTFIELD" SIZE="32" MAXLENGTH="5" ><P>
PASSWORD <INPUT TYPE="PASSWORD"  NAME="PASSWORD" MAXLENGTH="8"><P>
<P ALIGN="LEFT"><B>SELECT THE AREA IN WHICH YOU WANT TO BUY THESE THINGS:</B></P>
<SELECT NAME ="SELECT" SIZE="3" MULTIPLE>
<OPTION>DELHI</OPTION>
<OPTION>MUMBAI</OPTION>
<OPTION>CALCUTTA</OPTION>
<OPTION>AUSTRILIA</OPTION>
<OPTION>JERMANY</OPTION>
<OPTION>BRITISH</OPTION>
<OPTION>SOUHT AFRICA</OPTION>
<OPTION>BRITISH</OPTION>
</SELECT>
<P ALIGN="LEFT"><B> SELECT THE WAY BY WHICH YOU WILL GET THESE THINGS</B></P>
<SELECT NAME="SELECT">
<OPTION>--SELECT--</OPTION>
<OPTION>AIR</OPTION>
<OPTION>SHIP</OPTION>
<OPTION>TRAIN</OPTION></SELECT></P>
<P><B>CHOOSE THE CONTENT FOR BUY</B></P>
<P>
<INPUT TYPE="CHECKBOX" NAME="CHECKBOX" VALUE="CHECKBOX">
IPOD</P>
<P>
<INPUT TYPE="CHECKBOX" NAME="CHECKBOX" VALUE="CHEKBOX">
PDA
</P>
<P>
<INPUT TYPE="CHECKBOX" NAME="CHECKBOX" VALUE="CHECKBOX">
NOTEPAD</P>
<P><B>SELECT THE PRICE RANGE</B> </P>
<P>
<INPUT TYPE="RADIO" NAME="RADIO" VALUE="RADIO">
$0 TO $20
</P>
<P>
<INPUT TYPE="RADIO" NAME="RADIO" VALUE="RADIO">
$20 TO $40
</P>
<P>
<INPUT TYPE="RADIO" NAME="RADIO" VALUE="RADIO">
$40 TO $100
</P>
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="SUBMIT">

<INPUT TYPE="RESET" NAME="RESET" VALUE="CLEAR">
</BODY>
</HTML>

Glowing the Text Effect

Code for glowing the Text

 <HTML>
<BODY>
<SPAN STYLE="position:relative; width:200; height:25; filter:glow (color=#3C0DF0,strength=2)">
<A href="MOUSEOVER COLOR.HTML">THIS IS THE GLOWING TEXT CLICK HERE</A></SPAN>
</BODY>
</HTML>


Mouse Over Text Description

<HTML>
<BODY>

 <A HREF="http://www.ORKUT.COM/" TITLE="THIS IS THE LINK BY WHICH YOU CAN LINK WITH ORKUT

&#13

&#13

&#13

&#13

&#13
CLICK here
and more...

">CLICK HERE TO LINK A WEB SITE</A>
</BODY>
</HTML>

Mouse over Alert

 <html>
<body>
<a href="" onMouseOver="alert('HEY HATT HATT CHALL BHAGG')">YAHA AA JALDI</a>
</body>
</html>

Mouse Over Color Change

 <HTML>
<BODY>

<TABLE BORDER="2" CELLPADDING="2" WIDTH="100%">
<TR onMouseover="this.bgColor='#FFF000'"onMouseout="this.bgColor='#FFFFFF'">
<TD>Your Table Data</TD>
</TR>
<TR onMouseover="this.bgColor='#FF0000'"onMouseout="this.bgColor='#FFFFFF'">
<TD>Your Table Data</TD>
</TR>
<TR onMouseover="this.bgColor='#FFFCCC'"onMouseout="this.bgColor='#FFFFFF'">
<TD>Your Table Data</TD>
</TR>
</TABLE>
</BODY>
</HTML>

Open New window by HTML code

 <html.
<BOSY>
<A HREF="FORM ON WEB.HTML"
TARGET="TARGETWINDOW"> CLICK HERE TO DISPLAY FORM </A>
</BODY>
</HTML>

Simply paste/type this code in Notepad (by me)and save this with .htm/.html extension and run ….

Bullets in HTML

<HTML>
<BODY>
<MENU>
<LI TYPE=”disk”>TEA
<LI TYPE=”square”>COFFEE
<LI TYPE=”circle”>MILK
<LI TYPE=”right”>coldrink
</MENU>
</BODY>
</HTML>

Combo Box and Submit Button

<html>
<body>
<FORM METHOD=post ACTION=”/cgi-bin/example.cgi”>
Select an option:
<SELECT>
<OPTION SELECTED>~~SELECT~~<OPTION >COMPUTER
<OPTION>LAPTOP
<OPTION>MOBILE
<OPTION>PDA
<OPTION>IPOD
<OPTION>PALMTOP
</SELECT><BR>
<INPUT type=”Submit” VALUE=”Submit”></LEFT>
</FORM>
</body>
</html>

LINK for the songs

<HTML>
<HEAD>
<TITLE>
THIS IS MY PAGE
</TITLE>
</HEAD>
<BODY>
<A HREF = “D:\Latest songs\New songs1 KHDUA KE LIYE”>
CLICK TO LISTEN THE SONG </A>
</BODY>
</HTML>

Mouse Over Color

<HTML>
<BODY>

<TABLE BORDER=”2″ CELLPADDING=”2″ WIDTH=”100%”>
<TR onMouseover=”this.bgColor=’#FFF000′”onMouseout=”this.bgColor=’#FFFFFF’”>
<TD>Your Table Data</TD>
</TR>
<TR onMouseover=”this.bgColor=’#FF0000′”onMouseout=”this.bgColor=’#FFFFFF’”>
<TD>Your Table Data</TD>
</TR>
<TR onMouseover=”this.bgColor=’#FFFCCC’”onMouseout=”this.bgColor=’#FFFFFF’”>
<TD>Your Table Data</TD>
</TR>
</TABLE>
</BODY>
</HTML>

Link without underline

<html>
<body>
<a href=”E:\HTML SAMPLE PROGRAMS\NEW WINDOW BY LINK.HTML” STYLE=”TEXT-DECORATION=NONE”>
CLICK TO DISPLAY</A>
</BODY>
</HTML>

Link of emails

<html>
<body>
<A HREF=”mailto:nikhil.kmr.johar@gmail.com”>Contact Us</A>
</body>
</html>

_________________________________________________________________________________

These all are the codes of HTML and HTML is very much used in programming like in ASP.NET

these codes are simple but usually very much useful in creation of HTML pages

So follow steps and learn HTML

I prefer you to not copy and paste the code, read and type by yourself in your NOTEPAD and save with the .htm or .html extension

after saving the notepad file it will open in Internet Browser;

I hope you like this article and its working too ;-)

For more help contact me : i will be happy to help you

Thanks

Nikhil Kumar

Share SocialTwist Tell-a-Friend 

Movable form with designed Header (.dll)

January 3rd, 2010

Movable form with designed Header (.dll)

Background

Many times I have seen that many programmer creates designable hearder for their windows forms but then donsen’t have the fesility of moving like predifined windows forms, but after reading this article this is simple to create a .dll form header movable.

You can create any control movable on the form by this code…

Okay lets start to do this___

First step

First you have to create a Header by Windows Control Library in Visual Studio / any version.

After creating header just use this in your windows project as a usercontrol from toolbox after importing.

Interface

Coding

Here is the code in C#

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace Movable_Form

{

public partial class Form1 : Form

{

public int diff_x;

public int diff_y;

public bool mouse_down = false;

public Form1()

{

InitializeComponent();

}

private void Form1_MouseDown(object sender, MouseEventArgs e)

{

diff_x = Form.MousePosition.X - Form.ActiveForm.Location.X;

diff_y = Form.MousePosition.Y - Form.ActiveForm.Location.Y;

mouse_down = true;

}

private void Form1_MouseUp(object sender, MouseEventArgs e)

{

mouse_down = false;

}

private void button1_Click(object sender, EventArgs e)

{

Dispose();

this.Close();

}

private void Form1_MouseMove(object sender, MouseEventArgs e)

{

if (mouse_down == true)

{

Point p = new Point(MousePosition.X - diff_x, MousePosition.Y - diff_y);

Form.ActiveForm.Location = p;

}

}

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)

{

diff_x = Form.MousePosition.X - Form.ActiveForm.Location.X;

diff_y = Form.MousePosition.Y - Form.ActiveForm.Location.Y;

mouse_down = true;

}

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)

{

if (mouse_down == true)

{

Point p = new Point(MousePosition.X - diff_x, MousePosition.Y - diff_y);

Form.ActiveForm.Location = p;

}

}

private void pictureBox1_MouseUp(object sender, MouseEventArgs e)

{

mouse_down = false;

}

}

}

This is the Form1.Designer.cs code (Help you to understand Design control used)

namespace Movable_Form
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name=”disposing”>true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
this.userControl11 = new Movable_Header_Dll.UserControl1();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Image = global::Movable_Form.Properties.Resources.NRN;
this.pictureBox1.Location = new System.Drawing.Point(176, 64);
this.pictureBox1.Name = “pictureBox1″;
this.pictureBox1.Size = new System.Drawing.Size(171, 146);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove);
this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp);
//
// button1
//
this.button1.Location = new System.Drawing.Point(226, 216);
this.button1.Name = “button1″;
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = “Exit”;
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// userControl11
//
this.userControl11.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
this.userControl11.Location = new System.Drawing.Point(3, 0);
this.userControl11.Name = “userControl11″;
this.userControl11.Size = new System.Drawing.Size(438, 34);
this.userControl11.TabIndex = 2;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(443, 253);
this.Controls.Add(this.userControl11);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = “Form1″;
this.Text = “Form1″;
this.TransparencyKey = System.Drawing.SystemColors.ActiveCaption;
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseUp);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button1;
private Movable_Header_Dll.UserControl1 userControl11;
}
}


I Have provide this code because by reading this you can understand the design process of this form,There is no need to learn this code you can create your own stylish form

Now here you are seeing this form header is different and also movable

For further help contact me : I will happy to help you

Thanks

Nikhil  Kumar

Share SocialTwist Tell-a-Friend 

“Multiplayer” Player in C# (Perfect).

January 2nd, 2010

Introduction

Here we are going to create a sound player called “MultiPlayer” which is able to play all audio format files and some video format files also that’s why it’s called “Multiplayer”

And the most important thing about this player is simple programmig of c-# and a simple user interface provide better interactivity of users

A “Time” showing fesility which shows time in Minutes and seconds of playing files some buttons which provide better commands for using this player.

Download the whole project from here :

DOWNLOAD LINK

Programming

Here I import two.dll for playing these audio and video files

1- Interop.Shell32.dll

2- Interop.WMPLib.dll

I have commented the whole program which helps to understand it.

So now the time for programming:

Here is the program of c#___

//These Namespace which are to be used in this program

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Runtime.InteropServices;

// ^_^–^_^–^_^–READ CAREFULLY

// COMMENTS _^_^_———_^_^_—– @

namespace MP3_PLAYER

{

public partial class Form1 : Form

{

private int masterVolumn;

int sec;

int min;

string Command;

// Here the 128 is the default pitch of

StringBuilder sb = new StringBuilder(128);

// Here the simple method to import the Dll file of the wimdows media player for all systems…

[DllImport("winmm.dll")]

//You can’t use any other word in place of

// mciSendString because this is imported from winmm.dll …

// You can’t change the sequence of this initialization (_______)…if u will change this will show the error(s)…

public static extern long mciSendString(string rCommand, StringBuilder rReturn, int back, int length);

public Form1()

{

InitializeComponent();

//this.MasterVolume=5*100;

}

// This is the mouseover event for the browse button this is used for change the size

// of the button dynamically. . .

private void BTBROWSE_MouseMove(object sender, MouseEventArgs e)

{

BTBROWSE.Width = 115;

BTBROWSE.Height = 40;

BTBROWSE.BackColor = Color.Red;

BTBROWSE.ForeColor = Color.DarkTurquoise;

}

// This is a leave event for the browse button

// this will return the size of the button when u leave the button …

private void BTBROWSE_MouseLeave(object sender, EventArgs e)

{

BTBROWSE.Width = 110;

BTBROWSE.Height = 23;

BTBROWSE.BackColor = Color.Transparent;

BTBROWSE.ForeColor = Color.Black;

}

private void BTPLAY_MouseMove(object sender, MouseEventArgs e)

{

BTPLAY.Width = 115;

BTPLAY.Height = 40;

BTPLAY.BackColor = Color.Red;

BTPLAY.ForeColor = Color.DarkTurquoise;

}

private void BTPLAY_MouseLeave(object sender, EventArgs e)

{

BTPLAY.Width = 110;

BTPLAY.Height = 23;

BTPLAY.BackColor = Color.Transparent;

BTPLAY.ForeColor = Color.Black;

}

private void BTPAUSE_MouseMove(object sender, MouseEventArgs e)

{

BTPAUSE.Width = 115;

BTPAUSE.Height = 40;

BTPAUSE.BackColor = Color.Red;

BTPAUSE.ForeColor = Color.DarkTurquoise;

}

private void BTPAUSE_MouseLeave(object sender, EventArgs e)

{

BTPAUSE.Width = 110;

BTPAUSE.Height = 23;

BTPAUSE.BackColor = Color.Transparent;

BTPAUSE.ForeColor = Color.Black;

}

private void BTCLOSE_MouseMove(object sender, MouseEventArgs e)

{

BTCLOSE.Width = 115;

BTCLOSE.Height = 40;

BTCLOSE.BackColor = Color.Red;

BTCLOSE.ForeColor = Color.DarkTurquoise;

}

private void BTCLOSE_MouseLeave(object sender, EventArgs e)

{

BTCLOSE.Width = 110;

BTCLOSE.Height = 23;

BTCLOSE.BackColor = Color.Transparent;

BTCLOSE.ForeColor = Color.Black;

}

private void BTCLOSE_Click(object sender, EventArgs e)

{

System.Windows.Forms.DialogResult answer;

{

answer = MessageBox.Show(”Do You Really Want To Exit ? “, “Exit”, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

if (answer == System.Windows.Forms.DialogResult.No)

{

return;

}

else

{

Application.Exit();

}

}

}

private void button1_Click(object sender, EventArgs e)

{

About frmobj = new About();

frmobj.Show();

}

// this is used to browse your mp3 files …

private void BTBROWSE_Click(object sender, EventArgs e)

{

openFileDialog1.Filter = “Mp3 [.mp3] files |*.mp3|Movie [.avi] files|*.avi|Video [3GP] files|*.3GP|WAV [.wav] files|*.wav|DAT [.DAT] files|*.dat “;

if (openFileDialog1.ShowDialog() == DialogResult.OK)

{

path.Text = openFileDialog1.FileName;

Command = “close Mp3File”;

mciSendString(Command, null, 0, 0);

timer1.Enabled = false;

Command = “open ” + “\”" + openFileDialog1.FileName + “\”" + ” type MPEGVideo alias Mp3File”;

mciSendString(Command, null, 0, 0);

}

}

// this is used to play your mp3 files…

private void BTPLAY_Click(object sender, EventArgs e)

{

if (openFileDialog1.FileName == “”)

{

if (openFileDialog1.ShowDialog() == DialogResult.OK)

{

openFileDialog1.Filter = “Mp3 [.mp3] files |*.mp3|Movie [.avi] files|*.avi|Video [3GP] files|*.3GP|WAV [.wav] files|*.wav|DAT [.DAT] files|*.dat “;

//openFileDialog1.Filter = “JPEG Files|*.jpg|GIF Files|*.gif”;

Command = “open ” + “\”" + openFileDialog1.FileName + “\”" + ” type MPEGVideo alias Mp3File”;

mciSendString(Command, null, 0, 0);

Command = “play Mp3File”;

mciSendString(Command, null, 0, 0);

timer1.Enabled = true;

this.MasterVolume = this.MasterVolume;

}

}

else

{

Command = “play Mp3File”;

mciSendString(Command, null, 0, 0);

timer1.Enabled = true;

}

}

// this is used to pause your mp3 file and it will play the file from the paused time…

private void BTPAUSE_Click(object sender, EventArgs e)

{

Command = “pause mp3file”;

mciSendString(Command, null, 0, 0);

}

// this is used to show the time of mp3 file …

private void timer1_Tick(object sender, EventArgs e)

{

Command = “Status Mp3File position”;

mciSendString(Command, sb, 128, 0);

sec = int.Parse(sb.ToString());

sec = sec / 1000;

min = sec / 60;

sec = sec % 60;

ltime.Text = min.ToString(” 00 “) + “~” + sec.ToString(” 00 “);

}

// this will change the text box readonly , anybody can’t change the text at runtime …

private void Form1_Load(object sender, EventArgs e)

{

path.ReadOnly = true;

MasterVolume = masterVolume.Value * 100;

}

private void picprevw_MouseMove(object sender, MouseEventArgs e)

{

picprevw.Width = 130;

picprevw.Height = 40;

picprevw.BackColor = Color.Red;

picprevw.ForeColor = Color.DarkTurquoise;

}

private void picprevw_MouseLeave(object sender, EventArgs e)

{

picprevw.Width = 136;

picprevw.Height = 23;

picprevw.BackColor = Color.Transparent;

picprevw.ForeColor = Color.Black;

}

private void picprevw_Click(object sender, EventArgs e)

{

Picture_Preview frmobj = new Picture_Preview();

frmobj.Show();

}

public int MasterVolume

{

get

{

return masterVolumn; //Guess could be used to return Volume level: I don’t need it

}

set

{

mciSendString(string.Concat(”setaudio MediaFile volume to “, value), null, 0, 0);

masterVolumn = value;

}

}

private void masterVolume_Scroll(object sender, EventArgs e)

{

MasterVolume = masterVolume.Value * 100;

}

}

}

Here is the interface of Multiplayer

For further help contact me:

Keep reading…

Thanks

Nikhil Kumar

Share SocialTwist Tell-a-Friend 

Scientific Calculator in C#

January 2nd, 2010

Scientific Calculator In C-Sharp

Here are some namespaces which you will include

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


This is the coding for creating a scientific calculator

namespace calculator
{
public partial class Form1 : Form
{
calc.Class1 obj = new calc.Class1();
//calc.Class1 obj1 = new calc.Class1();

//Variables which you have to decalre

string sign; double r = 0;
double p;
bool count = false;
bool ff = false;
string sign1;
double d = 0; double temp;

double s;
bool check = false;
public Form1()
{
InitializeComponent();
}

public void button1_Click(object sender, EventArgs e)
{
if (check == true)
{
ff = true;
check = false;
textBox1.Text = “”;
}
textBox1.Text = Convert.ToString(textBox1.Text + button1.Text);
}

public void button2_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}

textBox1.Text = Convert.ToString(textBox1.Text + button2.Text);
}

public void button3_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}

textBox1.Text = Convert.ToString(textBox1.Text + button3.Text);
}

public void button4_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}

textBox1.Text = Convert.ToString(textBox1.Text + button4.Text);
}

public void button5_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}

textBox1.Text = Convert.ToString(textBox1.Text + button5.Text);
}

public void button6_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}

textBox1.Text = Convert.ToString(textBox1.Text + button6.Text);
}

public void button7_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}

textBox1.Text = Convert.ToString(textBox1.Text + button7.Text);
}

public void button8_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}

textBox1.Text = Convert.ToString(textBox1.Text + button8.Text);
}

public void button9_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}

textBox1.Text = Convert.ToString(textBox1.Text + button9.Text);
}

public void button10_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}

textBox1.Text = Convert.ToString(textBox1.Text + button10.Text);
}
/*public void button1_Click(object sender, EventArgs e)
{
i0f (check == true)
{
ff = true;
check = false;
textBox1.Text = “”;
}
textBox1.Text = Convert.ToString(textBox1.Text + button1.Text);
}*/

private void button11_Click(object sender, EventArgs e)
{

check = true;
s = double.Parse(textBox1.Text);
sign = Convert.ToString(button11.Text);
if (ff == true)
{
p = double.Parse(textBox1.Text);
textBox1.Text = Convert.ToString((r + p));
r = double.Parse(textBox1.Text);

ff = false;
}

}

private void button12_Click(object sender, EventArgs e)
{
check = true;
s = double.Parse(textBox1.Text);
sign = Convert.ToString(button12.Text);
}

private void button13_Click(object sender, EventArgs e)
{
check = true;
s = double.Parse(textBox1.Text);
sign = Convert.ToString(button13.Text);
}

private void button14_Click(object sender, EventArgs e)
{
check = true;
s = double.Parse(textBox1.Text);
sign = Convert.ToString(button14.Text);
}

private void button15_Click(object sender, EventArgs e)
{
temp = double.Parse(textBox1.Text);

textBox1.Text = Convert.ToString(obj.op(s, temp, sign));
}

private void button16_Click(object sender, EventArgs e)
{
textBox1.Text = “”;
}

private void button17_Click(object sender, EventArgs e)
{
string st;
st = textBox1.Text;
textBox1.Text = st.Substring(0, st.Length - 1);
}

private void button18_Click(object sender, EventArgs e)
{

s = double.Parse(textBox1.Text);
sign = button18.Text;
textBox1.Text = (obj.op(s, sign).ToString());
}

private void button19_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}
textBox1.Text = Convert.ToString((textBox1.Text + button19.Text));
}

private void button20_Click(object sender, EventArgs e)
{
textBox1.Text = “”;
}

private void button21_Click(object sender, EventArgs e)
{
s = double.Parse(textBox1.Text);
sign = button21.Text.ToString();
textBox1.Text = obj.op(s, sign).ToString();
}

private void button22_Click(object sender, EventArgs e)
{
s = double.Parse(textBox1.Text);
textBox1.Text = Convert.ToString(obj.op(s));
}

private void button23_Click(object sender, EventArgs e)
{
temp = double.Parse(textBox1.Text);
sign = button23.Text.ToString();
textBox1.Text = Convert.ToString(obj.op(temp, s, sign));

}

private void button24_Click(object sender, EventArgs e)
{
temp = double.Parse(textBox1.Text);
sign = button24.Text;
textBox1.Text = obj.op(temp, sign).ToString();
}

private void button25_Click(object sender, EventArgs e)
{
temp = double.Parse(textBox1.Text);
sign = button25.Text;
textBox1.Text = obj.op(temp, sign).ToString();
}

private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
//dec
//if (count ==false)
// {
long temp1 = long.Parse(textBox1.Text);
// sign1 = radioButton3.Text;

textBox1.Text = Convert.ToString(obj.op(sign, temp1, sign1));
// }
/*else
{
string temp2=textBox1.Text.ToString();
sign1=radioButton3.Text;
textBox1.Text = obj.op(temp2, sign).ToString() ;
}*/

}

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{ //bin
sign = radioButton1.Text;

//temp = double.Parse((textBox1.Text));
// sign = radioButton1.Text;
// double k = (obj.op(s, sign));
// textBox1.Text = (obj.op(s, sign).ToString());
}

private void button33_Click(object sender, EventArgs e)
{
temp = int.Parse(textBox1.Text);
sign = button33.Text;
textBox1.Text = (obj.op(temp, sign)).ToString();
}

private void button34_Click(object sender, EventArgs e)
{
temp = double.Parse(textBox1.Text);
sign = button34.Text;
textBox1.Text = (obj.op(temp, sign)).ToString();
}

private void button35_Click(object sender, EventArgs e)
{
temp = double.Parse(textBox1.Text);
sign = button35.Text;
textBox1.Text = (obj.op(temp, sign)).ToString();
}

private void button36_Click(object sender, EventArgs e)
{
temp = int.Parse(textBox1.Text);
sign = button36.Text;
textBox1.Text = (obj.op(temp, sign)).ToString();

}

private void button37_Click(object sender, EventArgs e)
{
check = true;
s = double.Parse(textBox1.Text);
sign = button37.Text;
}

private void button38_Click(object sender, EventArgs e)
{
decimal k = 22 / 7m;
textBox1.Text = Convert.ToString(k);
}

private void button39_Click(object sender, EventArgs e)
{
s = double.Parse(textBox1.Text);
sign = button39.Text;
textBox1.Text = (obj.op(s, sign).ToString());
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
//oct
//temp = double.Parse(textBox1.Text);
sign = radioButton2.Text;
//textBox1.Text = (obj.op(temp, sign).ToString());
}

private void radioButton4_CheckedChanged(object sender, EventArgs e)
{//hex
//temp = double.Parse(textBox1.Text);
//count = true;
sign = radioButton4.Text;
//textBox1.Text = (obj.op(temp, sign).ToString());

}

private void button27_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}
textBox1.Text = Convert.ToString(textBox1.Text + button27.Text);
}

private void button28_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}
textBox1.Text = Convert.ToString(textBox1.Text + button28.Text);
}

private void button29_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}
textBox1.Text = Convert.ToString(textBox1.Text + button29.Text);

}

private void button30_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}
textBox1.Text = Convert.ToString(textBox1.Text + button30.Text);
}

private void button31_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}
textBox1.Text = Convert.ToString(textBox1.Text + button31.Text);
}

private void button32_Click(object sender, EventArgs e)
{
if (check == true)
{
check = false;
textBox1.Text = “”;
}
textBox1.Text = Convert.ToString(textBox1.Text + button31.Text);
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{

System.Windows.Forms.DialogResult answer;

answer = MessageBox.Show(”Do you really want to exit_? “, “Exit”, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (answer == System.Windows.Forms.DialogResult.No)
{
return;
}
else
{
Application.Exit();

}
}

private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
abtfrm a = new abtfrm();
a.Show();
}
}
}

Here is the Interface of Scientific Calculator__



For further help :

Contact Me

Thanks

Nikhil Kumar

Share SocialTwist Tell-a-Friend 

A fast and very simple calculator in C#

January 2nd, 2010

A fast and very simple calculator


Introduction

I have seen that when we have two numbers and want more mathemetical operations between them even we have to write them again and again for different operations…

Now this problem has solved by this calculator this is simple to do more then one operations by just typing two numbers only once…

check it…

Here is the code to develop this smart calculator

Here is the c# code for creating a calculator in c# language…

I have used a simple programming language as for beginner

I have used Media; Namespace by using this namespace you are able to add sounds but only .wav (wav sounds) -Now the question where you use sounds and what is the use of using sounds in calculator

so the answer is : for different - different buttons you can use different - different sounds like for “+” button you can use “Plus.wav” sounds if you are not having this type of sounds then just use your mobile or any other multimedia device to load your sound and save that sound as .wav format if you are not able to save this file as .wav format then simply there are many softwares to convert the audio clips format.

So when you click the “+” Button the plus sound would appear that shows your calculator or another program more attractive

You can play sounds in a LOOP.

For playing sounds you have to add a code which is here___


SoundPlayer sp;

Add this code on the button click event_

sp.Play(”Your .wav sound path”);

These are namespaces which include

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

namespace calculator
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

#region “Declaration”
long  a;

#endregion

#region “Buttons”

private void button1_Click(object sender, EventArgs e)
{
a = Convert.ToInt64(textBox4.Text) + Convert.ToInt64(textBox4.Text);
textBox3.Text = Convert.ToString(a);
}

private void button3_Click(object sender, EventArgs e)
{
a = Convert.ToInt64(textBox4.Text) - Convert.ToInt64(textBox2.Text);
textBox3.Text = Convert.ToString(a);
}

private void button4_Click(object sender, EventArgs e)
{

a = Convert.ToInt64(textBox4.Text) * Convert.ToInt64(textBox2.Text);
textBox3.Text = Convert.ToString(a);

}

private void button5_Click(object sender, EventArgs e)
{

a = Convert.ToInt64(textBox4.Text) / Convert.ToInt64(textBox2.Text);
textBox3.Text = Convert.ToString(Convert.ToDecimal(a));
}

private void button6_Click(object sender, EventArgs e)
{
a = Convert.ToInt64(textBox4.Text) * Convert.ToInt64(textBox4.Text);
textBox3.Text = Convert.ToString(a);
}

private void button2_Click(object sender, EventArgs e)
{
textBox4.Focus();
textBox4.Text = “”;
textBox2.Text = “”;
textBox3.Text = “”;
}

private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void openCalculatorToolStripMenuItem_Click(object sender, EventArgs e)
{
Form1 a = new Form1();
DialogResult d = a.ShowDialog();
}

private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsLetter(e.KeyChar) == true)
{
MessageBox.Show(”Character values are not allowed  “, “Information”, MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Handled = true;
}
if (char.IsPunctuation(e.KeyChar) == true)
{
MessageBox.Show(”Symbols are not allowed  “, ” Information “, MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Handled = true;

}
}

private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsLetter(e.KeyChar) == true)
{
MessageBox.Show(”Character values are not allowed  “, “Information”, MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Handled = true;
}
if (char.IsPunctuation(e.KeyChar) == true)
{
MessageBox.Show(”Symbols are not allowed  “, ” Information “, MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Handled = true;

}
}

private void button7_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void helpTopicsToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(”C:\\WINDOWS\\Help\\calc.chm”);
}

#endregion

#region “About Calculator”

private void aboutCalculatorToolStripMenuItem_Click(object sender, EventArgs e)
{
About_Calculator a = new About_Calculator();
DialogResult k = a.ShowDialog();
}
}
}

#endregion

Here is the INTERFACE of Smart Calculator

Calculator.JPG


For further help
Contact Me.

Thanks
NIkhil kumar

Share SocialTwist Tell-a-Friend 

Send Mail To User On Registration With Login Details- Continue part…

January 2nd, 2010

After doing all the code your user interface will look like this_

You can modify your user Interface by just editing the source code…

I have used this interface because i am using this interface in my site also…

my site is a search engine…keep reading i will provide the link here

Now the time comes for doing C-Sharp coding, a interesting work of registration form…

C-Sharp code for Registration Form:

In this code i have used sending mail utility by which you are able to send email through asp.net.

which is also in my previous blogs.

In this code we are mailing the data to the user when he/she register through this form, the another thing is that this code is checking the “Email Id and UserId” if exists in data table this will not allow user to be register…

Now add this code on the Submit Button click event__

// Namespaces which you have to use

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

using System.Data.SqlClient;

using System.Net.Mail;

public partial class Register : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Button1_Click(object sender, EventArgs e)

{

SqlConnection con = new SqlConnection();

con.ConnectionString = “Your connection details”;

con.Open();

try

{

SqlDataAdapter adapter = new SqlDataAdapter(“Select * from tablename”, con);

SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter);

DataSet ds = new DataSet(“tablename “);

adapter.Fill(ds, ” tablename “);

DataRow row = ds.Tables["tablename "].NewRow();

row["FirstName"] = TextBox1.Text;

row["LastName"] = TextBox2.Text;

row["UserName"] = TextBox3.Text;

row["Password"] = TextBox4.Text;

row["ConfirmPassword"] = TextBox5.Text;

row["Email"] = TextBox6.Text;

row["Mobile"] = TextBox7.Text;

row["City"] = TextBox8.Text;

row["RegistrationDate"] = TextBox9.Text;

ds.Tables["tablename "].Rows.Add(row);

adapter.Update(ds, ” tablename “);

_fn();

Session["Username"] = TextBox3.Text.Trim();

Label1.Text = “Thanks “+TextBox1.Text+“! for joining us You have successfully joined our network.”;

TextBox1.Text = “”;

TextBox2.Text = “”;

TextBox3.Text = “”;

TextBox4.Text = “”;

TextBox5.Text = “”;

TextBox6.Text = “”;

TextBox7.Text = “”;

TextBox8.Text = “”;

Button2.Text = “OK”;

//Response.Redirect(”Home.aspx”);

}

catch (SqlException)

{

Label1.Text = “UserName or Email id already Exists.”;

}

con.Close();

}

protected void Button2_Click(object sender, EventArgs e)

{

Server.Transfer(“Home.aspx”);

}

private void _fn()

{

SmtpClient client = new SmtpClient();

MailMessage message = new MailMessage();

//client.DeliveryMethod = “PickupDirectoryFromIis”;

client.Host = “smtp.gmail.com”;

client.Port = 587;

client.UseDefaultCredentials = true;

client.Credentials = new System.Net.NetworkCredential(“yourgmailid@gmail.com”, “gmailidpassword”);

client.EnableSsl = true;

try

{

MailAddress SendFrom = new MailAddress(“yourgmailid@gmail.com”, “yoursitename.com”);

MailAddress SendTo = new MailAddress(TextBox6.Text);

message = new MailMessage(SendFrom, SendTo);

message.Subject = “My Website”;

message.Body = “Hello,”+TextBox1.Text+“<br/><br/> <b>Thank you ! For joining us.</b>”+“<br/><br/>Your UserName: “ +TextBox3.Text+“<br/> Your Password: “ +TextBox4.Text+“<br/>Your Registered Email Id: “+TextBox6.Text+“<br/><br/><br/>Regards<br/>http://www.yoursitename.com<br/> <br/>This is an Auto-Generated mail.”;

message.IsBodyHtml = true;

// set the mail’s priority to high

message.Priority = MailPriority.High;

client.Send(message);

}

catch (Exception ex)

{

Label1.Text = ex.Message;

}

}

}

For this you should have a table which contains all the fields which you have created in your source code.

For storing, Retriving and updating etc… details in table.

I have used Many Validating controls also in source code try to learn how to use them,

Required Field Validator is a very usefull controls these days for controls.

For further Details:

Contact Me_

Thanks
Nikhil Kumar

Share SocialTwist Tell-a-Friend 

Send Mail To User On Registration With Login Details:

January 1st, 2010

Send Mail To User On Registration With Login Details:

Introduction:

If you are beginner in ASP.NET or going to create a web site and you want to know/create a registration form which also provide you a fesility “that when any new user register on your site then a confirmation about user registration with login details should be send to provided email id.

Here is a nice article with such a simple programming in C-# (C-Sharp) which tells you how to send emails and this (Registration) fesility.

Requirements:

For this you have to know c-sharp, ASP.NET, HTML for creating user interface etc…

Source Code (For Designing User Interface in ASP.NET):

This is source code register.aspx___

If you know source code then it will be simple to understand this code, it’s a simple code just try to read this with patient J

Just read this code and drag all the controls which are used here

Download AJAX control Toolkit from Microsoft site.It’s free_

Register.aspx

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

<%@ Register Namespace=”AjaxControlToolkit” Assembly=”AjaxControlToolkit” TagPrefix=”cc1″%>

<!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>Register_</title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

<center>

<br />

<cc1:DropShadowExtender ID=”DropShadowExtender1″ runat=”server” Opacity=”0.5″ Radius=”10″ Rounded=”false” TargetControlID=”Panel1″ TrackPosition=”true” Width =”10″>

</cc1:DropShadowExtender>

<asp:ScriptManager ID=”ScriptManager1″ runat=”server”>

</asp:ScriptManager>

<br />

</center>

<center>

&nbsp;</center>

<center style=”color: red”>

<br />

<img src=”Images/keyboard_hand.jpg”style=”width: 140px; height: 56px”>

&nbsp; &nbsp; <b style=”color: red”>Fill in Your Details</b>

&nbsp;</center>

<center>

<asp:Panel ID=”Panel1″ runat=”server” ScrollBars=”Auto” Height=”378px” Width=”372px” BackColor=”DodgerBlue” Direction=”LeftToRight” Wrap=”False” BorderColor=”MidnightBlue”>

<table style=”width: 355px; height: 334px”>

<tbody>

<tr>

<td style=”width: 237px; height: 26px”>

First Name</td>

<td style=”width: 100px; height: 26px”>

<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox></td>

<td style=”width: 85px; height: 26px” align=”left”>

<asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”server” ErrorMessage=”Please Enter Name” ControlToValidate=”TextBox1″>*</asp:RequiredFieldValidator></td>

</tr>

<tr>

<td style=”width: 237px; height: 30px”>

Last Name</td>

<td style=”width: 100px; height: 30px”>

<asp:TextBox ID=”TextBox2″ runat=”server”></asp:TextBox></td>

<td style=”width: 85px; height: 30px” align=”left”>

<asp:RequiredFieldValidator ID=”RequiredFieldValidator2″ runat=”server” ErrorMessage=”Please Enter Last Name” ControlToValidate=”TextBox2″>*</asp:RequiredFieldValidator></td>

</tr>

<tr>

<td style=”width: 237px; height: 29px;”>

User Name</td>

<td style=”width: 100px; height: 29px;”>

<asp:TextBox ID=”TextBox3″ runat=”server”></asp:TextBox></td>

<td style=”width: 85px; height: 29px;” align=”left”>

<asp:RequiredFieldValidator ID=”RequiredFieldValidator3″ runat=”server” ErrorMessage=”Please Assign a User ID” ControlToValidate=”TextBox3″>*</asp:RequiredFieldValidator></td>

</tr>

<tr>

<td style=”width: 237px; height: 30px;”>

Password</td>

<td style=”width: 100px; height: 30px;”>

<asp:TextBox ID=”TextBox4″ runat=”server” TextMode=”Password” Font-Size=”Small” Height=”16px” Width=”140px”></asp:TextBox></td>

<td style=”width: 85px; height: 30px;” align=”left”>

<asp:RequiredFieldValidator ID=”RequiredFieldValidator4″ runat=”server” ErrorMessage=”Please enter a password” ControlToValidate=”TextBox4″>*</asp:RequiredFieldValidator></td>

</tr>

<tr>

<td style=”width: 237px; height: 30px;”>

Confirm Password</td>

<td style=”width: 100px; height: 30px;”>

<asp:TextBox ID=”TextBox5″ runat=”server” TextMode=”Password” Font-Size=”Small” Height=”16px” Width=”140px”></asp:TextBox></td>

<td style=”width: 85px; height: 30px;” align=”left”>

<asp:RequiredFieldValidator ID=”RequiredFieldValidator5″ runat=”server” ErrorMessage=”Please confirm password” ControlToValidate=”TextBox5″>*</asp:RequiredFieldValidator><asp:CompareValidator

ID=”CompareValidator1″ runat=”server” ErrorMessage=”Confirm password should be same” ControlToCompare=”TextBox4″ ControlToValidate=”TextBox5″>*</asp:CompareValidator></td>

</tr>

<tr>

<td style=”width: 237px; height: 30px;”>

Email-ID</td>

<td style=”width: 100px; height: 30px;”>

<asp:TextBox ID=”TextBox6″ runat=”server”></asp:TextBox></td>

<td style=”width: 85px; height: 30px;” align=”left”>

<asp:RequiredFieldValidator ID=”RequiredFieldValidator6″ runat=”server” ErrorMessage=”Please enter Email-id” ControlToValidate=”TextBox6″>*</asp:RequiredFieldValidator><asp:RegularExpressionValidator

ID=”RegularExpressionValidator2″ runat=”server” ErrorMessage=”Please enter valid email Address” ControlToValidate=”TextBox6″ ValidationExpression=”\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*”>*</asp:RegularExpressionValidator></td>

</tr>

<tr>

<td style=”width: 237px; height: 29px;”>

Mobile No.</td>

<td style=”width: 100px; height: 29px;”>

<asp:TextBox ID=”TextBox7″ runat=”server”></asp:TextBox><br />

<asp:Label ID=”ex” runat=”server” Text=”12 or 13 Digits” Font-Size=”Smaller” Width=”138px” /></td>

<td style=”width: 85px; height: 29px;” align=”left”>

<asp:RequiredFieldValidator ID=”RequiredFieldValidator7″ runat=”server” ErrorMessage=”Please enter mobile no.” ControlToValidate=”TextBox7″>*</asp:RequiredFieldValidator><asp:RegularExpressionValidator

ID=”RegularExpressionValidator1″ runat=”server” ErrorMessage=”Enter Mobile No. with std. code” ControlToValidate=”TextBox7″ ValidationExpression=”^((\d{2})|(\d{3}))?(\d{10}){1}?$”>*</asp:RegularExpressionValidator></td>

</tr>

<tr>

<td style=”width: 237px; height: 30px”>

City</td>

<td style=”width: 100px; height: 30px”>

<asp:TextBox ID=”TextBox8″ runat=”server”></asp:TextBox></td>

<td align=”left” style=”width: 85px; height: 30px”>

<asp:RequiredFieldValidator ID=”RequiredFieldValidator8″ runat=”server” ErrorMessage=”Please enter you city name” Text=”*” ControlToValidate=”TextBox8″></asp:RequiredFieldValidator></td>

</tr>

<tr>

<td style=”height: 1px” colspan=”3″ align=”center” valign=”middle”>

&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;

<asp:Button ID=”Button1″ runat=”server” Text=”Submit” Width=”67px” Height=”22px” OnClick=”Button1_Click” /><asp:Button ID=”Button2″ runat=”server” Text=”Cancel” Height=”22px” Width=”67px” OnClick=”Button2_Click” CausesValidation=”false” /><asp:TextBox

ID=”TextBox9″ runat=”server” ></asp:TextBox></td>

</tr>

</tbody>

</table><center>

&nbsp; <asp:Label ID=”Label1″ runat=”server” Font-Size=”Smaller” ForeColor=”Red”></asp:Label></center>

<center>

<asp:ValidationSummary ID=”ValidationSummary1″ runat=”server” Font-Size=”Small” Height=”14px” Width=”255px” /></center>

</asp:Panel>

&nbsp;

</center>

</div>

</form>

</body>

</html>

In My next article under same “TAG” you will read this (article) further part…

Continue…

Share SocialTwist Tell-a-Friend 

Some New Articles

December 25th, 2009

Just i am improving myself about asp.net and after some time i will share this all…

Wait my friends sorry for incontinence ..

Thanks

Nikhil Kumar


Ready to proceed again…

November 25th, 2009

Hey friends now i will start blogging again on pending Ajax Control so please keep reading…

Thanks

Nikhil Kumar


Send E-Mails In ASP.NET with BCc And Cc

September 22nd, 2009

Hi

Today we will learn how to send E-Mails in ASP.NET with BCc And Cc if you have learn my previous article there we have learned how to send emails in asp.net but there was no option to send email more then one so here we will create a email sending tool by which we will able to send email more then one user at same time…

First off all What is BCc and Cc

Cc ->

Cc stands for carbon copy which means that whose address appears after the Cc: header would receive a copy of the message. Also, the Cc header would also appear inside the header of the received message.

BCc ->

Bcc stands for blind carbon copy which is similar to that of Cc except that the Email address of the recipients specified in this field do not appear in the received message header and the recipients in the To or Cc fields will not know that a copy sent to these address.

So lets start to create email sending tool in asp.net …..

First type this code in source code window to create the user interface of email-sending tool by using html code…

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>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>

<table align=”center” bgcolor=”#FF99FF” cellpadding=”10″ cellspacing=”3″
class=”style8″ frame=”box” title=”n-eMail Server”>
<caption align=”top”
style=”font-family: ‘Franklin Gothic Book’; font-size: x-large; text-decoration: blink; font-weight: bold; font-style: inherit; font-variant: normal; color: #FF0000″>
n - eMail Server</caption>
<tr>
<td bgcolor=”#FF99FF” class=”style8″>
Emai ID</td>
<td class=”style5″>
<asp:TextBox ID=”txtemail” runat=”server” Width=”186px”></asp:TextBox>
</td>
</tr>
<tr>
<td class=”style6″>
Password</td>
<td class=”style7″>
<asp:TextBox ID=”txtpass” runat=”server” Width=”184px” TextMode=”Password”></asp:TextBox>
</td>
</tr>
<tr>
<td class=”style6″>
CC</td>
<td class=”style7″>
<asp:TextBox ID=”txtcc” runat=”server” Width=”184px”></asp:TextBox>
</td>
</tr>
<tr>
<td class=”style6″>
BCC</td>
<td class=”style7″>
<asp:TextBox ID=”txtbcc” runat=”server” Height=”21px” Width=”185px”></asp:TextBox>
</td>
</tr>
<tr>
<td class=”style8″>
To</td>
<td class=”style5″>
<asp:TextBox ID=”txtTo” runat=”server” Width=”186px”></asp:TextBox>
</td>
</tr>
<tr>
<td class=”style8″>
From</td>
<td class=”style5″>
<asp:TextBox ID=”txtFrom” runat=”server” Width=”186px”></asp:TextBox>
</td>
</tr>
<tr>
<td class=”style8″>
Subject</td>
<td class=”style5″>
<asp:TextBox ID=”txtSub” runat=”server” Width=”185px”></asp:TextBox>
</td>
</tr>
<tr>
<td class=”style4″>
Message</td>
<td class=”style2″>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
<asp:TextBox ID=”txtMessage” runat=”server” Height=”128px” TextMode=”MultiLine”
Width=”318px”></asp:TextBox>
</td>
</tr>
<tr>
<td class=”style8″>
Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td class=”style5″>
<asp:TextBox ID=”txtStatus” runat=”server” Width=”311px” ForeColor=”#FF3300″></asp:TextBox>
</td>
</tr>
<tr>
<td class=”style8″>
&nbsp;</td>
<td class=”style5″>
<asp:Button ID=”btnSend” runat=”server” BackColor=”#FF99FF” BorderStyle=”Solid”
ForeColor=”#CC00FF” Text=”Send” Width=”178px” onclick=”btnSend_Click” />
</td>
</tr>
</table>

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

Now your Email sending tool Interface will look like this…

Now type this code in the send button click event

Default.aspx.cs

Add a namespace

using System.Net.Mail;

_________________________________________________________________

protected void btnSend_Click(object sender, EventArgs e)
{
SmtpClient client = new SmtpClient();
MailMessage message = new MailMessage();

client.Port = 587;
client.Host = “smtp.gmail.com”;
client.UseDefaultCredentials = true;
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential(txtemail.Text, txtpass.Text);

try
{
MailAddress sendto = new MailAddress(txtTo.Text);
MailAddress sendfrom = new MailAddress(txtFrom.Text);

message = new MailMessage(sendfrom, sendto);

message.Body = txtMessage.Text;
message.Subject = txtSub.Text;

// For including the cc email address…
message.CC.Add(txtcc.Text);
// For including the bcc email address…
message.Bcc.Add(txtbcc.Text);

// This will send the emails…
client.Send(message);

txtStatus.Text = “E-Mail(s)has been sent”;

}
catch (Exception ex)
{
txtStatus.Text = ex.ToString();
}

}

Now we are able to send E-Mails more then one user..

In my next upcoming blog we will learn how to send attachments also…

To keep reading…


Thanks

Nikhil Kumar

Share SocialTwist Tell-a-Friend