Create Free Blog | Random Blog »   Report Abuse | Login   

 
 

Countries List with Nationality.

February 5th, 2010

Here is list of countries with the insert command to be inserted in a table named Country.

after running the whole queries you can bind your table with Combo Box or any other control after that your control will be able to show the Countries list.

Create table COUNTRYLIST (CountryName char(40), Nationality char(40))

Run these queries…

INSERT INTO COUNTRYLIST VALUES (’Afghanistan’,'Afghan’)

INSERT INTO COUNTRYLIST VALUES (’Albania’,'Albanian’)

INSERT INTO COUNTRYLIST VALUES (’Algeria’,'Algerian’)

INSERT INTO COUNTRYLIST VALUES (’Andorra’,'Andorran’)

INSERT INTO COUNTRYLIST VALUES (’Angola’,'Angolan’)

INSERT INTO COUNTRYLIST VALUES (’Antigua and Barbuda’,'Antiguans,

Barbudans’)

INSERT INTO COUNTRYLIST VALUES (’Argentina’,'Argentinean’)

INSERT INTO COUNTRYLIST VALUES (’Armenia’,'Armenian’)

INSERT INTO COUNTRYLIST VALUES (’Australia’,'Australian’)

INSERT INTO COUNTRYLIST VALUES (’Austria’,'Austrian’)

INSERT INTO COUNTRYLIST VALUES (’Azerbaijan’,'Azerbaijani’)

INSERT INTO COUNTRYLIST VALUES (’The Bahamas’,'Bahamian’)

INSERT INTO COUNTRYLIST VALUES (’Bahrain’,'Bahraini’)

INSERT INTO COUNTRYLIST VALUES (’Bangladesh’,'Bangladeshi’)

INSERT INTO COUNTRYLIST VALUES (’Barbados’,'Barbadian’)

INSERT INTO COUNTRYLIST VALUES (’Belarus’,'Belarusian’)

INSERT INTO COUNTRYLIST VALUES (’Belgium’,'Belgian’)

INSERT INTO COUNTRYLIST VALUES (’Belize’,'Belizean’)

INSERT INTO COUNTRYLIST VALUES (’Benin’,'Beninese’)

INSERT INTO COUNTRYLIST VALUES (’Bhutan’,'Bhutanese’)

INSERT INTO COUNTRYLIST VALUES (’Bolivia’,'Bolivian’)

INSERT INTO COUNTRYLIST VALUES (’Bosnia and Herzegovina’,'Bosnian,

Herzegovinian’)

INSERT INTO COUNTRYLIST VALUES (’Botswana’,'Motswana (singular), Batswana

(plural)’)

INSERT INTO COUNTRYLIST VALUES (’Brazil’,'Brazilian’)

INSERT INTO COUNTRYLIST VALUES (’Brunei’,'Bruneian’)

INSERT INTO COUNTRYLIST VALUES (’Bulgaria’,'Bulgarian’)

INSERT INTO COUNTRYLIST VALUES (’Burkina Faso’,'Burkinabe’)

INSERT INTO COUNTRYLIST VALUES (’Burundi’,'Burundian’)

INSERT INTO COUNTRYLIST VALUES (’Cambodia’,'Cambodian’)

INSERT INTO COUNTRYLIST VALUES (’Cameroon’,'Cameroonian’)

INSERT INTO COUNTRYLIST VALUES (’Canada’,'Canadian’)

INSERT INTO COUNTRYLIST VALUES (’Cape Verde’,'Cape Verdian’)

INSERT INTO COUNTRYLIST VALUES (’Central African Republic’,'Central African’)

INSERT INTO COUNTRYLIST VALUES (’Chad’,'Chadian’)

INSERT INTO COUNTRYLIST VALUES (’Chile’,'Chilean’)

INSERT INTO COUNTRYLIST VALUES (’China’,'Chinese’)

INSERT INTO COUNTRYLIST VALUES (’Colombia’,'Colombian’)

INSERT INTO COUNTRYLIST VALUES (’Comoros’,'Comoran’)

INSERT INTO COUNTRYLIST VALUES (’Congo, Republic of the’,'Congolese’)

INSERT INTO COUNTRYLIST VALUES (’Congo, Democratic Republic of

the’,'Congolese’)

INSERT INTO COUNTRYLIST VALUES (’Costa Rica’,'Costa Rican’)

INSERT INTO COUNTRYLIST VALUES (’Cote d”Ivoire’,'Ivorian’)

INSERT INTO COUNTRYLIST VALUES (’Croatia’,'Croatian’)

INSERT INTO COUNTRYLIST VALUES (’Cuba’,'Cuban’)

INSERT INTO COUNTRYLIST VALUES (’Cyprus’,'Cypriot’)

INSERT INTO COUNTRYLIST VALUES (’Czech Republic’,'Czech’)

INSERT INTO COUNTRYLIST VALUES (’Denmark’,'Danish’)

INSERT INTO COUNTRYLIST VALUES (’Djibouti’,'Djibouti’)

INSERT INTO COUNTRYLIST VALUES (’Dominica’,'Dominican’)

INSERT INTO COUNTRYLIST VALUES (’Dominican Republic’,'Dominican’)

INSERT INTO COUNTRYLIST VALUES (’East Timor’,'East Timorese’)

INSERT INTO COUNTRYLIST VALUES (’Ecuador’,'Ecuadorean’)

INSERT INTO COUNTRYLIST VALUES (’Egypt’,'Egyptian’)

INSERT INTO COUNTRYLIST VALUES (’El Salvador’,'Salvadoran’)

INSERT INTO COUNTRYLIST VALUES (’Equatorial Guinea’,'Equatorial Guinean’)

INSERT INTO COUNTRYLIST VALUES (’Eritrea’,'Eritrean’)

INSERT INTO COUNTRYLIST VALUES (’Estonia’,'Estonian’)

INSERT INTO COUNTRYLIST VALUES (’Ethiopia’,'Ethiopian’)

INSERT INTO COUNTRYLIST VALUES (’Fiji’,'Fijian’)

INSERT INTO COUNTRYLIST VALUES (’Finland’,'Finnish’)

INSERT INTO COUNTRYLIST VALUES (’France’,'French’)

INSERT INTO COUNTRYLIST VALUES (’Gabon’,'Gabonese’)

INSERT INTO COUNTRYLIST VALUES (’The Gambia’,'Gambian’)

INSERT INTO COUNTRYLIST VALUES (’Georgia’,'Georgian’)

INSERT INTO COUNTRYLIST VALUES (’Germany’,'German’)

INSERT INTO COUNTRYLIST VALUES (’Ghana’,'Ghanaian’)

INSERT INTO COUNTRYLIST VALUES (’Greece’,'Greek’)

INSERT INTO COUNTRYLIST VALUES (’Grenada’,'Grenadian’)

INSERT INTO COUNTRYLIST VALUES (’Guatemala’,'Guatemalan’)

INSERT INTO COUNTRYLIST VALUES (’Guinea’,'Guinean’)

INSERT INTO COUNTRYLIST VALUES (’Guinea-Bissau’,'Guinea-Bissauan’)

INSERT INTO COUNTRYLIST VALUES (’Guyana’,'Guyanese’)

INSERT INTO COUNTRYLIST VALUES (’Haiti’,'Haitian’)

INSERT INTO COUNTRYLIST VALUES (’Honduras’,'Honduran’)

INSERT INTO COUNTRYLIST VALUES (’Hungary’,'Hungarian’)

INSERT INTO COUNTRYLIST VALUES (’Iceland’,'Icelander’)

INSERT INTO COUNTRYLIST VALUES (’India’,'Indian’)

INSERT INTO COUNTRYLIST VALUES (’Indonesia’,'Indonesian’)

INSERT INTO COUNTRYLIST VALUES (’Iran’,'Iranian’)

INSERT INTO COUNTRYLIST VALUES (’Iraq’,'Iraqi’)

INSERT INTO COUNTRYLIST VALUES (’Ireland’,'Irish’)

INSERT INTO COUNTRYLIST VALUES (’Israel’,'Israeli’)

INSERT INTO COUNTRYLIST VALUES (’Italy’,'Italian’)

INSERT INTO COUNTRYLIST VALUES (’Jamaica’,'Jamaican’)

INSERT INTO COUNTRYLIST VALUES (’Japan’,'Japanese’)

INSERT INTO COUNTRYLIST VALUES (’Jordan’,'Jordanian’)

INSERT INTO COUNTRYLIST VALUES (’Kazakhstan’,'Kazakhstani’)

INSERT INTO COUNTRYLIST VALUES (’Kenya’,'Kenyan’)

INSERT INTO COUNTRYLIST VALUES (’Kiribati’,'I-Kiribati’)
INSERT INTO COUNTRYLIST VALUES (’Korea, North’,'North Korean’)

INSERT INTO COUNTRYLIST VALUES (’Korea, South’,'South Korean’)

INSERT INTO COUNTRYLIST VALUES (’Kuwait’,'Kuwaiti’)

INSERT INTO COUNTRYLIST VALUES (’Kyrgyz Republic’,'Kirghiz’)

INSERT INTO COUNTRYLIST VALUES (’Laos’,'Laotian’)

INSERT INTO COUNTRYLIST VALUES (’Latvia’,'Latvian’)

INSERT INTO COUNTRYLIST VALUES (’Lebanon’,'Lebanese’)

INSERT INTO COUNTRYLIST VALUES (’Lesotho’,'Mosotho’)

INSERT INTO COUNTRYLIST VALUES (’Liberia’,'Liberian’)

INSERT INTO COUNTRYLIST VALUES (’Libya’,'Libyan’)

INSERT INTO COUNTRYLIST VALUES (’Liechtenstein’,'Liechtensteiner’)

INSERT INTO COUNTRYLIST VALUES (’Lithuania’,'Lithuanian’)

INSERT INTO COUNTRYLIST VALUES (’Luxembourg’,'Luxembourger’)

INSERT INTO COUNTRYLIST VALUES (’Macedonia’,'Macedonian’)

INSERT INTO COUNTRYLIST VALUES (’Madagascar’,'Malagasy’)

INSERT INTO COUNTRYLIST VALUES (’Malawi’,'Malawian’)

INSERT INTO COUNTRYLIST VALUES (’Malaysia’,'Malaysian’)

INSERT INTO COUNTRYLIST VALUES (’Maldives’,'Maldivan’)

INSERT INTO COUNTRYLIST VALUES (’Mali’,'Malian’)

INSERT INTO COUNTRYLIST VALUES (’Malta’,'Maltese’)

INSERT INTO COUNTRYLIST VALUES (’Marshall Islands’,'Marshallese’)

INSERT INTO COUNTRYLIST VALUES (’Mauritania’,'Mauritanian’)

INSERT INTO COUNTRYLIST VALUES (’Mauritius’,'Mauritian’)

INSERT INTO COUNTRYLIST VALUES (’Mexico’,'Mexican’)

INSERT INTO COUNTRYLIST VALUES (’Federated States of

Micronesia’,'Micronesian’)

INSERT INTO COUNTRYLIST VALUES (’Moldova’,'Moldovan’)

INSERT INTO COUNTRYLIST VALUES (’Monaco’,'Monegasque’)

INSERT INTO COUNTRYLIST VALUES (’Mongolia’,'Mongolian’)

INSERT INTO COUNTRYLIST VALUES (’Morocco’,'Moroccan’)

INSERT INTO COUNTRYLIST VALUES (’Mozambique’,'Mozambican’)

INSERT INTO COUNTRYLIST VALUES (’Myanmar (Burma)’,'Burmese’)

INSERT INTO COUNTRYLIST VALUES (’Namibia’,'Namibian’)

INSERT INTO COUNTRYLIST VALUES (’Nauru’,'Nauruan’)

INSERT INTO COUNTRYLIST VALUES (’Nepal’,'Nepalese’)

INSERT INTO COUNTRYLIST VALUES (’Netherlands’,'Dutch’)

INSERT INTO COUNTRYLIST VALUES (’New Zealand’,'New Zealander’)

INSERT INTO COUNTRYLIST VALUES (’Nicaragua’,'Nicaraguan’)

INSERT INTO COUNTRYLIST VALUES (’Niger’,'Nigerien’)

INSERT INTO COUNTRYLIST VALUES (’Nigeria’,'Nigerian’)

INSERT INTO COUNTRYLIST VALUES (’Norway’,'Norwegian’)

INSERT INTO COUNTRYLIST VALUES (’Oman’,'Omani’)

INSERT INTO COUNTRYLIST VALUES (’Pakistan’,'Pakistani’)

INSERT INTO COUNTRYLIST VALUES (’Palau’,'Palauan’)

INSERT INTO COUNTRYLIST VALUES (’Panama’,'Panamanian’)

INSERT INTO COUNTRYLIST VALUES (’Papua New Guinea’,'Papua New Guinean’)

INSERT INTO COUNTRYLIST VALUES (’Paraguay’,'Paraguayan’)

INSERT INTO COUNTRYLIST VALUES (’Peru’,'Peruvian’)

INSERT INTO COUNTRYLIST VALUES (’Philippines’,'Filipino’)

INSERT INTO COUNTRYLIST VALUES (’Poland’,'Polish’)

INSERT INTO COUNTRYLIST VALUES (’Portugal’,'Portuguese’)

INSERT INTO COUNTRYLIST VALUES (’Qatar’,'Qatari’)

INSERT INTO COUNTRYLIST VALUES (’Romania’,'Romanian’)

INSERT INTO COUNTRYLIST VALUES (’Russia’,'Russian’)

INSERT INTO COUNTRYLIST VALUES (’Rwanda’,'Rwandan’)

INSERT INTO COUNTRYLIST VALUES (’Saint Kitts and Nevis’,'Kittian and Nevisian’)

INSERT INTO COUNTRYLIST VALUES (’Saint Lucia’,'Saint Lucian’)

INSERT INTO COUNTRYLIST VALUES (’Samoa’,'Samoan’)

INSERT INTO COUNTRYLIST VALUES (’San Marino’,'Sammarinese’)

INSERT INTO COUNTRYLIST VALUES (’Sao Tome and Principe’,'Sao Tomean’)

INSERT INTO COUNTRYLIST VALUES (’Saudi Arabia’,'Saudi Arabian’)

INSERT INTO COUNTRYLIST VALUES (’Senegal’,'Senegalese’)

INSERT INTO COUNTRYLIST VALUES (’Serbia and Montenegro’,'Serbian’)

INSERT INTO COUNTRYLIST VALUES (’Seychelles’,'Seychellois’)

INSERT INTO COUNTRYLIST VALUES (’Sierra Leone’,'Sierra Leonean’)

INSERT INTO COUNTRYLIST VALUES (’Singapore’,'Singaporean’)

INSERT INTO COUNTRYLIST VALUES (’Slovakia’,'Slovak’)

INSERT INTO COUNTRYLIST VALUES (’Slovenia’,'Slovene’)

INSERT INTO COUNTRYLIST VALUES (’Solomon Islands’,'Solomon Islander’)

INSERT INTO COUNTRYLIST VALUES (’Somalia’,'Somali’)

INSERT INTO COUNTRYLIST VALUES (’South Africa’,'South African’)

INSERT INTO COUNTRYLIST VALUES (’Spain’,'Spanish’)

INSERT INTO COUNTRYLIST VALUES (’Sri Lanka’,'Sri Lankan’)

INSERT INTO COUNTRYLIST VALUES (’Sudan’,'Sudanese’)

INSERT INTO COUNTRYLIST VALUES (’Suriname’,'Surinamer’)

INSERT INTO COUNTRYLIST VALUES (’Swaziland’,'Swazi’)

INSERT INTO COUNTRYLIST VALUES (’Sweden’,'Swedish’)

INSERT INTO COUNTRYLIST VALUES (’Switzerland’,'Swiss’)

INSERT INTO COUNTRYLIST VALUES (’Syria’,'Syrian’)

INSERT INTO COUNTRYLIST VALUES (’Taiwan’,'Taiwanese’)

INSERT INTO COUNTRYLIST VALUES (’Tajikistan’,'Tadzhik’)

INSERT INTO COUNTRYLIST VALUES (’Tanzania’,'Tanzanian’)

INSERT INTO COUNTRYLIST VALUES (’Thailand’,'Thai’)

INSERT INTO COUNTRYLIST VALUES (’Togo’,'Togolese’)

INSERT INTO COUNTRYLIST VALUES (’Tonga’,'Tongan’)

INSERT INTO COUNTRYLIST VALUES (’Trinidad and Tobago’,'Trinidadian’)

INSERT INTO COUNTRYLIST VALUES (’Tunisia’,'Tunisian’)

INSERT INTO COUNTRYLIST VALUES (’Turkey’,'Turkish’)

INSERT INTO COUNTRYLIST VALUES (’Turkmenistan’,'Turkmen’)

INSERT INTO COUNTRYLIST VALUES (’Tuvalu’,'Tuvaluan’)

INSERT INTO COUNTRYLIST VALUES (’Uganda’,'Ugandan’)

INSERT INTO COUNTRYLIST VALUES (’Ukraine’,'Ukrainian’)

INSERT INTO COUNTRYLIST VALUES (’United Arab Emirates’,'Emirian’)

INSERT INTO COUNTRYLIST VALUES (’United Kingdom’,'British’)

INSERT INTO COUNTRYLIST VALUES (’United States’,'American’)

INSERT INTO COUNTRYLIST VALUES (’Uruguay’,'Uruguayan’)

INSERT INTO COUNTRYLIST VALUES (’Uzbekistan’,'Uzbekistani’)

INSERT INTO COUNTRYLIST VALUES (’Vanuatu’,'Ni-Vanuatu’)

INSERT INTO COUNTRYLIST VALUES (’Vatican City (Holy See)’,'none’)

INSERT INTO COUNTRYLIST VALUES (’Venezuela’,'Venezuelan’)

INSERT INTO COUNTRYLIST VALUES (’Vietnam’,'Vietnamese’)

INSERT INTO COUNTRYLIST VALUES (’Yemen’,'Yemeni’)

INSERT INTO COUNTRYLIST VALUES (’Zambia’,'Zambian’)

INSERT INTO COUNTRYLIST VALUES (’Zimbabwe’,'Zimbabwean’)

Thanks

Nikhil Kumar

Share SocialTwist Tell-a-Friend 

Upload Large Files in SQL in an ASP.NET web application:

January 30th, 2010

Upload Large Files in SQL in an ASP.NET web application:

In this article we learn how to upload large files in sql sever database by using asp.net file upload control

FileUploadLarge.aspx

<%@ Page Language=”C#” %>

<%@ Import Namespace=”System.IO” %>

<%@ Import Namespace=”System.Data” %>

<%@ Import Namespace=”System.Data.SqlClient” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”

“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<script runat=”server”>

const string conString = @”Server=SAI;Integrated Security=True; initial catalog=master”;

void btnAdd_Click(Object s, EventArgs e)

{

if (upFile.HasFile)

{

if (CheckFileType(upFile.FileName))

{

AddFile(upFile.FileName, upFile.FileContent);

rptFiles.DataBind();

}

}

}

bool CheckFileType(string fileName)

{

return Path.GetExtension(fileName).ToLower() == “.doc”;

}

void AddFile(string fileName, Stream upload)

{

SqlConnection con = new SqlConnection(conString);

SqlCommand cmd = new SqlCommand(“INSERT Files (FileName) Values (@FileName);” + “SELECT @Identity = SCOPE_IDENTITY()”, con);

cmd.Parameters.AddWithValue(“@FileName”, fileName);

SqlParameter idParm = cmd.Parameters.Add(“@Identity”, SqlDbType.Int);

idParm.Direction = ParameterDirection.Output;

using (con)

{

con.Open();

cmd.ExecuteNonQuery();

int newFileId = (int)idParm.Value;

StoreFile(newFileId, upload, con);

}

}

void StoreFile(int fileId, Stream upload, SqlConnection connection)

{

int bufferLen = 8040;

BinaryReader br = new BinaryReader(upload);

byte[] chunk = br.ReadBytes(bufferLen);

SqlCommand cmd = new SqlCommand(“UPDATE Files SET FileBytes=@Buffer WHERE Id=@FileId”, connection);

cmd.Parameters.AddWithValue(“@FileId”, fileId);

cmd.Parameters.Add(“@Buffer”, SqlDbType.VarBinary, bufferLen).Value = chunk;

cmd.ExecuteNonQuery();

SqlCommand cmdAppend = new SqlCommand(“UPDATE Files SET FileBytes .WRITE(@Buffer, NULL, 0) WHERE Id=@FileId”, connection);

cmdAppend.Parameters.AddWithValue(“@FileId”, fileId);

cmdAppend.Parameters.Add(“@Buffer”, SqlDbType.VarBinary, bufferLen);

chunk = br.ReadBytes(bufferLen);

while (chunk.Length > 0)

{

cmdAppend.Parameters["@Buffer"].Value = chunk;

cmdAppend.ExecuteNonQuery();

chunk = br.ReadBytes(bufferLen);

}

br.Close();

}

</script>

<html xmlns=”http://www.w3.org/1999/xhtml” >

<head id=”Head1″ runat=”server”>

<title>FileUpload Large</title>

</head>

<body>

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

<div>

<asp:Label

id=”lblFile”

Text=”Word Document:”

AssociatedControlID=”upFile”

Runat=”server” />

<asp:FileUpload

id=”upFile”

Runat=”server” />

<asp:Button

id=”btnAdd”

Text=”Add Document”

OnClick=”btnAdd_Click”

Runat=”server” />

<hr />

<asp:Repeater

id=”rptFiles”

DataSourceID=”srcFiles”

Runat=”server”>

<HeaderTemplate>

<ul class=”fileList”>

</HeaderTemplate>

<ItemTemplate>

<li>

<asp:HyperLink

id=”lnkFile”

Text=’<%#Eval(”FileName”)%>

NavigateUrl=’<%#Eval(”Id”, “~/FileHandlerLarge.ashx?id={0}”)%>

Runat=”server” />

</li>

</ItemTemplate>

<FooterTemplate>

</ul>

</FooterTemplate>

</asp:Repeater>

<asp:SqlDataSource id=”srcFiles” ConnectionString=”Server=SAI;Integrated Security=True; Initial catalog=master;” SelectCommand=”SELECT Id,FileName FROM Files”

runat=”server” />

</div>

</form>

</body>

</html>

Now add a .ashx file and use this code in it

<%@ WebHandler Language=”C#” Class=”FileHandlerLarge” %>

using System;

using System.Web;

using System.Data;

using System.Data.SqlClient;

public class FileHandlerLarge : IHttpHandler {

const string conString = @”Server=SAI;Integrated Security=True;Initial catalog= master”;

public void ProcessRequest (HttpContext context)

{context.Response.Buffer = false;

context.Response.ContentType = “application/msword”;

SqlConnection con = new SqlConnection(conString);

SqlCommand cmd = new SqlCommand(“SELECT FileBytes FROM Files WHERE Id=@Id”, con);

cmd.Parameters.AddWithValue(“@Id”, context.Request["Id"]);

using (con)

{

con.Open();

SqlDataReader reader = cmd.ExecuteReader

(CommandBehavior.SequentialAccess);

if (reader.Read())

{

int bufferSize = 8040;

byte[] chunk = new byte[bufferSize];

long retCount;

long startIndex = 0;

retCount = reader.GetBytes(0, startIndex, chunk, 0, bufferSize);

while (retCount == bufferSize)

{

context.Response.BinaryWrite(chunk);

startIndex += bufferSize;

retCount = reader.GetBytes(0, startIndex, chunk, 0, bufferSize);

}

byte[] actualChunk = new Byte[retCount - 1];

Buffer.BlockCopy(chunk, 0, actualChunk, 0, (int)retCount - 1);

context.Response.BinaryWrite(actualChunk);

}

}

}

public bool IsReusable {

get {

return false;

}

}

}

In web.config file under System.web tag add this line

<httpRuntime maxRequestLength=10240

requestLengthDiskThreshold=100 />

Conclusion:

NOTE : This article is excerpted for the BOOK “ASP.NET 3.5 Unleashed” by Stephen Walther

Here we learned how to use fileupload control to save large files

You have to browse .doc files here

Thanks !!!

For further help feel free to contact me B)

ignitesofthelp@gmail.com

Interface:

Share SocialTwist Tell-a-Friend 

Multivew with view control seems like replacing Masterpages

January 28th, 2010

Multiview in asp.net

Here by this article we learn how to use Multiview and View in asp.net

Multiview is very usefull you can use it instead of content pages for master pages.

First

Write this code in asp.net first page

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>View Control Example</title>
</
head>
<
body>

<form id=”Form” runat=”server”>

<div id=”header”>
<h1>
ASP.NET Multiview
</h1>
</div>
<div id=”sidebar”>
<div id=”nav”>
&nbsp;
</div>
</div>
<div id=”content”>
<div class =”itemContent” >
<div>

<asp:Label ID=”Label1″ runat=”server” Font-Bold=”True”

Font-Size=”Medium”

Font-Underline=”True” Text=”View and MultiView Controls Example”></asp:Label>
<br />
<br />
<asp:Button id=”Button1″ runat=”server” Text=”Click Me to See View1″

OnClick=”Button1_Click” BackColor=”Black” ForeColor=”#00CCFF” /> &nbsp;

<asp:Button id=”Button2″ runat=”server” Text=”Click Me to See View2″

OnClick=”Button2_Click” BackColor=”Black” ForeColor=”#00CCFF” /> &nbsp;

<asp:Button id=”Button3″ runat=”server” Text=”Click Me to See View3″

OnClick=”Button3_Click” BackColor=”Black” ForeColor=”#00CCFF” />

<br /><br />

<asp:MultiView id=”MultiView1″ runat=”server” ActiveViewIndex=0>
<asp:View id=”View1″ runat=”server”>
<a style=”font-family: ‘Times New Roman’, Times, serif”>I am Dwayne</a> <br />
<br />
<asp:Image ID=”Image1″ runat=”server” Height=”132px” ImageUrl=”dwaynejohnson.jpg” Width=”92px” />
<br />
</asp:View>
<asp:View id=”View2″ runat=”server”>
<a style=”font-family: ‘Times New Roman’, Times, serif” >I am Nikhil</a>
<br />
<br />
<asp:Image ID=”Image2″ runat=”server” ImageUrl=”My pic.jpg”/>
</asp:View>
<asp:View id=”View3″ runat=”server”>
<a style=”font-family: ‘Times New Roman’, Times, serif”>I am a progress bar</a>
<br />
<br />

<asp:Image ID=”Image3″ runat=”server”ImageUrl=”Loading1.gif” />
</asp:View>
</asp:MultiView>

<br />
<br />
<br />

<br />
<br />
<div id=”footer”>

</div>
</div>
</div>

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

Declaration:

Here we are creating three buttons for three views(under MultiView Control)

All buttons are changing the view and evrey view is having another contents

Here you have to paste three images in your solution explorer I have used here

1- dwaynejohnson.jpg

2- My pic.jpg

3- Loading1.gif

We have created One MultiView control and three View controls under Multiview control.

Note: You can use many View controls under MultiView controls as per your requirements.

Under view controls we are using image controls

You can use anycontrol which you want in place of image control.

Second:

Now add this code

Default.aspx.cs:

 

using System;
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;
public
partial class _Default : System.Web.UI.Page

{
protected void Page_Load(object sender, EventArgs e)
{
MultiView1.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
MultiView1.Visible = true;
MultiView1.SetActiveView(View1);
}
protected void Button2_Click(object sender, EventArgs e)
{
MultiView1.Visible = true;
MultiView1.SetActiveView(View2);
}
protected void Button3_Click(object sender, EventArgs e)
{
MultiView1.Visible = true;
MultiView1.SetActiveView(View3);
}
}


Declaration:
Here on the page loading the Multiview is invisible
When you click the first button it will show the first view control
When you click the second button it will show the second view control
When you click the third button it will show the third view control
SetActiveView is using for set the active view.

Interface:

MultiView.JPG

Conclusion:

Here we learn how to use MultiView control in asp.net which works like a master page and its content pages.

If you feel help then contact me I will be happy to help you …

Thanks

Nikhil Kumar

Share SocialTwist Tell-a-Friend 

FileUploadControl uploading and saving images and showing in DataList dynamically:-

January 27th, 2010

FileUploadControl uploading and saving images and showing in DataList dynamically:-

Here by this article we learn how to use FileUploadControl to upload Images in a folder under your web project and show them in a DataList control by using image control under ItemTemplate.

First-

In the Default.aspx page create a label, FileUploadControl; button and a DataList Control then Under ItemTemplate add an image control…

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>Upload Control:DataList</title>

</head>

<body>

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

<div>

<asp:Label ID=”lbl” runat=”server”>Please upload your image…</asp:Label>

<br />

<asp:FileUpload ID=”fileupload” runat=”server” Width=”273px” />

<br />

<br />

<asp:Button ID =”btnadd” runat=”server” Text=”Add Image” OnClick=”btnadd_Click” />

<hr />

<asp:DataList ID=”dl” runat=”server” Height=”123px” RepeatColumns=”2″ Width=”97px” >

<ItemTemplate>

<asp:Image ID=”img” runat=”server” Width=”200px” ImageUrl=’<%# Eval(”Name”, “~/UploadedFiles/{0}”) %> />

<br />

<%#Eval(”Name”) %>

</ItemTemplate>

</asp:DataList>

</div>

</form>

</body>

</html>

Second:

Now add this C# code for doing all the activities…

Default.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.IO;

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

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void btnadd_Click(object sender, EventArgs e)

{

if (fileupload.HasFile)

{

if (CheckFileType(fileupload.FileName))

{

string filepath = “~/UploadedFiles/” + fileupload.FileName;

fileupload.SaveAs(MapPath(filepath));

}

}

}

bool CheckFileType(string fileName)

{

string ext = Path.GetExtension(fileName);

switch (ext.ToLower())

{

case “.gif”:

return true;

case “.png”:

return true;

case “.jpg”:

return true;

case “.jpeg”:

return true;

default:

return false;

}

}

void Page_PreRender()

{

string upFolder = MapPath(“~/UploadedFiles/”);

DirectoryInfo dir = new DirectoryInfo(upFolder);

dl.DataSource = dir.GetFiles();

dl.DataBind();

}

}

Declaration:

Here is a function named CheckFileType using for checking the file type which we are going to upload

This fuction allows only four types of image files if there is another type it will trow error, so this is for restriction.

btnadd_Click is using to show the images in imagecontrol.

HasFile is using to check there is there any file uploaded or not.

SaveAs enables you to save the uploaded file to the file system.

FileName—Enables you to get the name of the uploaded file.

Here we used _

<asp:Image ID=”img” runat=”server” Width=”200px” ImageUrl=’<%# Eval(”Name”, “~/UploadedFiles/{0}”) %> />

If you don’t specify the Width then the output would look bad, because images show in real size but now every uploaded image show in 200px width.

Another point to learn is UploadedFiles this is a folder created in Solution Explorer in current website

When you click the btnadd button that image will save in UploadedFiles folder its good because we don’t have to learn the path if we save this in system folder.

Uploadcontrol with datalist.JPG

Conclution:

Here we learn how to save images in folder under project folder, how to use imagecontrol in DataList control to show images.

Reference: This article is created by using the help of ASP.NET 3.5 Unleashed by Stephen Walther.

IF you want help regarding this article feel free to contact me I will be happy to assist you…

Thanks

Nikhil Kumar

Share SocialTwist Tell-a-Friend 

Google API in ASP.NET

January 26th, 2010

Google API in ASP.NET

Here is an article to show how to implement or use Google API in Asp.NET.

Background

Using Google API means you are using google searching in your website

First Step:-

For using Google API you should have a Google Account for this just simply create a Gmail Account which is free of cost.

Then you have to get the Google API key this is also free, simply search on google for Google API key.

Secong Step:-

Now create an ASP.Net website and add this code to Defaul.aspx page

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>Google API:</title>

</head>

<body>

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

<div>

<strong><span style=”font-size: 16pt; color: #ff0000; font-family: Courier New CE”>

Google API In ASP.NET </span></strong>

<br />

<br />

<hr style=”font-weight: bold; color: #006600; height: 5px”/>

<asp:Label ID=”lblmsg” runat=”server” Text=”"></asp:Label>

<br />

<br />

<asp:TextBox ID=”txtsearch” runat=”server” BackColor=”#FFFFC0″ BorderColor=”Black” Width=”321px” Height=”18px” ></asp:TextBox>

<asp:Button ID=”btn1″ runat=”server” Text=”Search” BackColor=”#FFFFC0″ BorderColor=”#80FF80″ ForeColor=”#004000″ OnClick=”btn1_Click” Width=”95px” />

<br />

<br />

<hr style=”font-weight: bold; color: #ff3333; height: 1px; text-decoration: line-through” />

</div>

</form>

</body>

</html>

Interface (Defaul.aspx)

Default.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

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

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void btn1_Click(object sender, EventArgs e)

{

if (txtsearch.Text.Trim().Length == 0)

{

lblmsg.Text = “Please enter your query to search…”;

}

else

{

Response.Redirect(“SearchDetails.aspx?q=”+txtsearch.Text);

}

}

}

VB.NET Code [If you are using VB inplace of C#]:-

Third Step:-

Add a new .aspx page and give the name “SearchResult.aspx”.

Fourth Step:-

Add this code to

SearchResult.aspx:-

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

<!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>Google Search…</title>

<script src=”http://www.google.com/jsapi?key=Add your key here” type=”text/javascript”></script>

<script language=”Javascript” type=”text/javascript”>

//<![CDATA[

google.load('search', '1');

function OnLoad() {

var searchControl = new google.search.SearchControl();

// Add in a full set of searchers

var localSearch = new google.search.LocalSearch();

searchControl.addSearcher(localSearch);

searchControl.addSearcher(new google.search.WebSearch());

searchControl.addSearcher(new google.search.VideoSearch());

searchControl.addSearcher(new google.search.BlogSearch());

searchControl.addSearcher(new google.search.NewsSearch());

searchControl.addSearcher(new google.search.ImageSearch());

searchControl.addSearcher(new google.search.BookSearch());

searchControl.addSearcher(new google.search.PatentSearch());

searchControl.draw(document.getElementById("myCtrl"));

// execute an inital search

searchControl.execute(GetQueryString("q"));

}

google.setOnLoadCallback(OnLoad);

//]]>

// Function to get Query String Value

function GetQueryString(query) {

hu = window.location.search.substring(1);

gy = hu.split(“&”);

for (i = 0; i < gy.length; i++) {

ft = gy[i].split(“=”);

if (ft[0] == query) {

return ft[1];

}

}

}

</script>

</head>

<body>

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

<div id=”myCtrl” style=”width:100%”>

</div>

</form>

</body>

</html>

NOTE: Add you key here = Copy your key from Google and paste in place of “add your key here

If you feel any problem in getting Google API key, then contact me I will be happy to help you J

OutPut:-

When you enter some query in textbox and click the search button it will redirect this page to SearchResult.aspx page where we are using script provided by Google.

Note: When you are getting Google API Key then you have to enter the website name, there you have enter http://www.google.com.

Conclusion:-

Here we learn how to use Google API in ASP.NET.

For further help feel free to contact me: i will be happy to help you :)

Thanks !!!

Nikhil Kumar

Share SocialTwist Tell-a-Friend 

Google Search from ASP.NET

January 26th, 2010

Google Search from ASP.NET

Here by this article we will learn how to search on google based on the query write in textbox

Here is a textbox and a button, write your search text in textbox and click the button, the button redirect you to google with the search result written in textbox…

CODES____

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>Google Search</title>

</head>

<body>

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

<div>

<asp:Label ID=”lbl” runat=”server” Width=”120px”>Google Search…</asp:Label><br />

<asp:Label ID=”Label1″ runat=”server” ForeColor=”Red” Style=”z-index: 100; left: 14px;

position: absolute; top: 95px”></asp:Label>

<br />

<asp:TextBox ID=”txt” runat=”server” Height=”19px” Width=”293px” ></asp:TextBox>

<asp:Button ID=”btnsearch” runat=”server” Text=”Search Google” Height=”25px” OnClick=”btnsearch_Click” Width=”137px” />

</div>

</form>

</body>

</html>

Default.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

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

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void btnsearch_Click(object sender, EventArgs e)

{

if (txt.Text.Trim().Length == 0)

{

Label1.Text = “Please enter text to search”;

}

else

{

Response.Redirect(“http://www.google.com/search?q=” + txt.Text);

}

}

}

Interface

Thanks !!!

for further help… feel free to contact me :

Nikhil Kumar

Share SocialTwist Tell-a-Friend 

Google Search from Windows Application:

January 18th, 2010

Google Search from Windows Application:

Here is a tool developed in C# Windows Application which allows you to search on google

based on your query which you give in textbox.

The layout of this tool is :

Coding:

The coding is almost simple

C#

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.IO;

namespace SearchTool

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

if (queryBox.Text.Trim().Length==0)

{

label1.Text = “Please enter text to search”;

return;

}

else

{

string nikhilkumar = “http://www.google.com/search?q=” + queryBox.Text;

webBrowser1.Navigate(nikhilkumar);

}

}

private void button2_Click(object sender, EventArgs e)

{

webBrowser1.GoBack();

}

private void button3_Click(object sender, EventArgs e)

{

webBrowser1.GoForward();

}

private void button4_Click(object sender, EventArgs e)

{

webBrowser1.GoSearch();

}

}

}

VB.NET

  1. Imports System
  2. Imports System.Collections.Generic
  3. Imports System.ComponentModel
  4. Imports System.Data
  5. Imports System.Drawing
  6. Imports System.Text
  7. Imports System.Windows.Forms
  8. Imports System.IO
  9. Namespace SearchTool
  10. Public Partial Class Form1
  11. Inherits Form
  12. Public Sub New()
  13. InitializeComponent()
  14. End Sub
  15. Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
  16. If queryBox.Text.Trim().Length = 0 Then
  17. label1.Text = “Please enter text to search”
  18. Exit Sub
  19. Else
  20. Dim nikhilkumar As String = “http://www.google.com/search?q=” & queryBox.Text
  21. webBrowser1.Navigate(nikhilkumar)
  22. End If
  23. End Sub
  24. Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)
  25. webBrowser1.GoBack()
  26. End Sub
  27. Private Sub button3_Click(ByVal sender As Object, ByVal e As EventArgs)
  28. webBrowser1.GoForward()
  29. End Sub
  30. Private Sub button4_Click(ByVal sender As Object, ByVal e As EventArgs)
  31. webBrowser1.GoSearch()
  32. End Sub
  33. End Class
  34. End Namespace

Here when you enter any word in Textbox and click on the Search Button the result will come in the

WebBroswerControl based on the query which you enter in the textbox

Back and Forward Buttons are used used to back and forward you search J

Thanks !

Share SocialTwist Tell-a-Friend 

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