Happy New Year 2013...

Happy New Year 2013 to all of you....

Run Commands Listed In Alphabetical Order

Here are the Run Commands for Windows Operating System listed in Alphabetic Order.

Run Command
Accessibility Controls
Accessibility Wizard
Add Hardware Wizard
Add/Remove Programs
Administrative Tools
control admintools
Adobe Acrobat ( if installed )
Adobe Distiller ( if installed )
Adobe ImageReady ( if installed )
Adobe Photoshop ( if installed )
Automatic Updates
Basic Media Player
Bluetooth Transfer Wizard
Ccleaner ( if installed )
C: Drive
Certificate Manager
Character Map
Check Disk Utility
Clipboard Viewer
Command Prompt
Command Prompt
Component Services
Computer Management
Compare Files
Control Panel
Create a shared folder Wizard
Date and Time Properties
DDE Shares
Device Manager
Direct X Control Panel ( if installed )
Direct X Troubleshooter
Disk Cleanup Utility
Disk Defragment
Disk Partition Manager
Display Properties
control desktop
Display Properties
Display Properties (w/Appearance Tab Preselected )
control color
Dr. Watson System Troubleshooting Utility
Driver Verifier Utility
Ethereal ( if installed )
Event Viewer
Files and Settings Transfer Tool
File Signature Verification Tool
Folders Properties
control folders
Fonts Folder
Free Cell Card Game
Game Controllers
Group Policy Editor ( xp pro )
Hearts Card Game
Help and Support
Hotline Client
Iexpress Wizard
Indexing Service
Internet Connection Wizard
Internet Properties
Internet Setup Wizard
IP Configuration (Display Connection Configuration)
ipconfig /all
IP Configuration (Display DNS Cache Contents)
ipconfig /displaydns
IP Configuration (Delete DNS Cache Contents)
ipconfig /flushdns
IP Configuration (Release All Connections)
ipconfig /release
IP Configuration (Renew All Connections)
ipconfig /renew
IP Configuration (Refreshes DHCP & Re-Registers DNS)
ipconfig /registerdns
IP Configuration (Display DHCP Class ID)
ipconfig /showclassid
IP Configuration (Modifies DHCP Class ID)
ipconfig /setclassid
Java Control Panel ( if installed )
Java Control Panel ( if installed )
Keyboard Properties
control keyboard
Local Security Settings
Local Users and Groups
Logs You Out of Windows
Malicious Software Removal Tool
Microsoft Access ( if installed )
Microsoft Chat
Microsoft Excel ( if installed )
Microsoft Diskpart
Microsoft Frontpage ( if installed )
Microsoft Movie Maker
Microsoft Management Console
Microsoft Narrator
Microsoft Paint
Microsoft Powerpoint
Microsoft Word ( if installed )
Microsoft Syncronization Tool
Minesweeper Game
Mouse Properties
control mouse
Mouse Properties
MS-Dos Editor

Remaining commands on next post.
Drop a comment below to reach me or provide feedback on above post.

Happy to Help. 
Glad to Be,
John Bhatt

List All SQL Server Instances in Combo (Windows Form) - Part-2

Hello Friends,
On the Previous Post on this series, I have told you the code and procedure upto Connect Button. Hope you have been through it and enjoyed that. If not, please read below post before moving ahead. http://blog.johnbhatt.com/2012/10/list-all-sql-server-instances-in-combo.html
Today, I am going to share rest of the Code for Listing Database, Tables Inside Database and Columns and apply them with Operator and simply perform Select Operation from database and list the Result in DataGrid. Let's look the Design you have previously saw when making connection.

In above design,
In Database Combo, we will list all database from Connected Server. Then in Table Combo, we will list all Tables of Selected Database and in Column Combo all columns of Selected Table.

Lets Begin the Code. On Button Click and Successful Connection, we will load all database names in Database Combo. Actually we have did it earlier.
Lets have look at this Code:
                   if (checkBox1.Checked == true)
                       ConStr = "Data Source = " + comboBox1.Text.ToString() + ";Integrated Security = true;";
                       ConStr = "Data Source = " + comboBox1.Text.ToString() + ";UID=" + textBox1.Text + ";pwd=" + textBox2.Text + ";";
                   SqlConnection Conexion = new SqlConnection(ConStr);
                   label9.Visible = false;
                   panel2.Visible = false;
                   button2.Visible = true;
                   panel1.Visible = true;
                   groupBox1.Visible = true;
                   DataTable tblDatabases = Conexion.GetSchema("Databases");
                   for (int i = 0; i <= tblDatabases.Rows.Count - 1; i++)

This is code from earlier post.
Now Lets see the Code on SelectedIndex Change event of Database Combo (Combobox2).
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
            SqlConnection conx = new SqlConnection(ConStr + "Database ="+comboBox2.Text.ToString()+";");
            DataTable tblTables = conx.GetSchema("Tables");
            for (int i = 0; i <= tblTables.Rows.Count - 1; i++)
Here we are creating Connection String Everytime, because, It is changing every-time. Now this code will list all the Tables inside Database in Table Combo (combobox3): Code:
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
            SqlConnection conx = new SqlConnection(ConStr + "Database =" + comboBox2.Text.ToString() + ";");
            string tableName = comboBox3.SelectedItem.ToString();
            SqlDataAdapter adp = new SqlDataAdapter("select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = '"+comboBox3.SelectedItem.ToString()+"'",conx);
            DataTable tblColumns = new DataTable();
            for (int i = 0; i <= tblColumns.Rows.Count - 1; i++)

Now above code will make all Columns of Selected table from database.
Now Directly move to Keyword TextBox textchange event which will load data as you type.
private void textBox3_TextChanged(object sender, EventArgs e)
            string QueryCon = ConStr;
            if (comboBox5.Text.ToString() == "like")
                QueryStr = "SELECT * FROM " + comboBox3.Text.ToString() + " WHERE " + comboBox4.Text.ToString() + " " + comboBox5.Text.ToString() + " '%" + textBox3.Text + "%'";
                QueryStr = "SELECT * FROM " + comboBox3.Text.ToString() + " WHERE " + comboBox4.Text.ToString() + " " + comboBox5.Text.ToString() + " '" + textBox3.Text + "'";
            TxtQueryBox.Text = ConStr + "Database=" + comboBox2.Text.ToString() + ";"+"\n" + QueryStr;
            SqlDataAdapter adp = new SqlDataAdapter(QueryStr, ConStr+"Database="+comboBox2.Text.ToString()+";");
            DataSet ds = new DataSet();
            dataGridView1.DataSource = ds.Tables[0];

This will load data in GridView automatically. Lets see a snapshot once again with Result.
All the Best, Enjoy....

List All SQL Server Instances in Combo (Windows Form)


I was checking my Old Projects and Like to share a simple example with. Why not to create a SQL Management Application.

How we would do this? What is our objective?

Lets be clear.
We will List All SQL Server Instances available in Network into Application.
Then We will connect to Server using Windows Authentication or SQL Server Authentication.
After successfull authentication ,
We will list all databases in Instance.
After Database, we will List All Tables in Database,
After Database , we will list All Columns in Selected table.
We will place a Create button next to Database, Table list box also.
After selecting a Column, we provided a Filter (operator) and parameters in box.
Which will fetch data and display in DataGridView.

First we Designed a Following Screen.

In Servers List we have to Load All List of Servers and Connect. We have Options for Username and Password and also a Checkbox for Integrated Security (Windows Authentication).
Lets See the Code in Form Load.
Namespace to Include:
using System.Data.Sql;
using System.Data.SqlClient;

Now Form_Load Event Code
private void Form1_Load(object sender, EventArgs e)
            panel1.Visible = false;
            groupBox1.Visible = false;
            label9.Visible = true;
            label9.TextAlign = ContentAlignment.MiddleCenter;
            SqlDataSourceEnumerator SerInstances = SqlDataSourceEnumerator.Instance;
            DataTable SerNames = SerInstances.GetDataSources();
            for (int i = 0; i <= SerNames.Rows.Count - 1; i++)

Description of Above Code: We have placed rest design in Panel and Groupbox so we set that invisible on Form Load. Please Make a Conncetion First.. is Label9 and we set is Visible and aligned. Now main task is to List Sql Servers on Network. For this we used SqlDataSourceEnumerator class. In Next Line we take a DataTable and stored ServerInstances into that. Rest is Simple, We added all items into Listbox. Column 0 contains Machine name and Column 1 contains Instance Name. So we combined that at the Time of Adding to ComboBox Control. Now Click the Connect Button:
 private void button1_Click(object sender, EventArgs e)
            if (checkBox1.Checked == true && textBox1.Text.Trim().Length > 0)
                MessageBox.Show("Please Uncheck Integrated Security or Clear UserName!", this.Text + " - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else if (checkBox1.Checked == false && textBox1.Text.Trim().Length == 0)
                MessageBox.Show("Please Check Integrated Security or Enter UserName!", this.Text + " - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else if (textBox1.Text.Trim().Length > 0 && textBox2.Text.Trim().Length == 0)
                errorProvider1.SetError(textBox2, "Please enter password for Username = " + textBox1.Text + "!");
            else if (comboBox1.Text.Trim().Length == 0)
                MessageBox.Show("Please select Server from List. If You can not see any Instance in Servers Combobox, Contact your Network Administrator!", this.Text + " - Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                if (MessageBox.Show("Connection Successfull!, You are Now Connected to Server: " + comboBox1.Text.ToString() + "!", this.Text + " - Alert", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                    if (checkBox1.Checked == true)
                        ConStr = "Data Source = " + comboBox1.Text.ToString() + ";Integrated Security = true;";
                        ConStr = "Data Source = " + comboBox1.Text.ToString() + ";UID=" + textBox1.Text + ";pwd=" + textBox2.Text + ";";
                    SqlConnection Conexion = new SqlConnection(ConStr);
                    label9.Visible = false;
                    panel2.Visible = false;
                    button2.Visible = true;
                    panel1.Visible = true;
                    groupBox1.Visible = true;
                    DataTable tblDatabases = Conexion.GetSchema("Databases");

                    for (int i = 0; i <= tblDatabases.Rows.Count - 1; i++)

Description of Code: We Put some Validation and Message box to make some user friendly environment. After getting Proper Username and password, we make a Connection String and Used Username and password in Connection String. We build a connection, Make Servers List, Username and password and Connect button invisible and Disconnect button Visible. Then First we loaded all Databases of Selected Instance using Connection.GetSchema() method. How it look after connecting.
For now, its your turn to code something for this. I'll be back soon with Rest Part of This Program. Comments are Welcome. Feedback keep the Important Role in Improvement. So Expecting those from you. Happy Learning! John Bhatt
Glad to Know, Free to Share.....

At Gurgaon, Haryana, India

Accordion Panel with CSS

Greetings from John!,
Hope you all are enjoying.
Friends I am back with a new thing for you. Today I am going to show you, how to make a Good Accordion Panel.

Do you know, what is Accordion Panel? You must have seen some tables or Div's in website, that are collapsing and expanding on just Click. You can also call them Collapsible Div or Table.

ASP.NET Ajax Tools make it so Simpler for ASP.NET. You just need to link AjaxControlToolkit.dll to your bin folder and use it in the Page.
Let's add a new Web Form in Solution, this is the Page, where you want to add your collapsible div or table what may contain anything.

Source Code for Design above is here.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Accordian with CSS >> P.Yar.B Complex</title>
    <%--<link href="Accordian.css" rel="stylesheet" />--%>

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        <table width="100%" border="0">
                <td colspan="2" align="center">
                    <h1>Accordian with CSS</h1>
                <td colspan="3" align="center">
                    <asp:Accordion ID="Accordion1" runat="server" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" Width="490px">
                            <asp:AccordionPane ID="pane1" runat="server">
                                    Mouse<br />
                                    KeyBoard<br />
                                    <br />
                                    Printer<br />
                                    CPU<br />
                                    Speakers<br />
                            <asp:AccordionPane ID="pane2" runat="server">
                                <Header>Operating System</Header>
                                    MS Windows<br />
                                    Linux<br />
                                    Android<br />
                                    Mac<br />
                            <asp:AccordionPane ID="pane3" runat="server">
                                <Header>.NET IDE</Header>
                                    Visual Studio<br />
                                    Visual Web Developer<br />
                                    SharpDevelop<br />
                            <asp:AccordionPane ID="pane4" runat="server">
                                <Header>John Bhatt</Header>
                                    <a href="http://www.johnbhatt.com" target="_blank">Portal Home</a><br />
                                    <a href="http://blog.johnbhatt.com" target="_blank">Blog of P.Yar.B</a><br />
                                    <a href="http://media.johnbhatt.com" target="_blank">Download Center</a><br />

Now Let's See the CSS, what is on CSS.
.accordionHeader {
    border: 1px solid #2F4F4F;
    color: white;
    background-color: #2E4d7B;
    font-family: Arial, Sans-Serif;
    font-size: 12px;
    font-weight: bold;
    padding: 5px;
    margin-top: 5px;
    cursor: pointer;

#master_content .accordionHeader a {
    color: #FFFFFF;
    background: none;
    text-decoration: none;

    #master_content .accordionHeader a:hover {
        background: none;
        text-decoration: underline;

.accordionHeaderSelected {
    border: 1px solid #2F4F4F;
    color: white;
    background-color: #5078B3;
    font-family: Arial, Sans-Serif;
    font-size: 12px;
    font-weight: bold;
    padding: 5px;
    margin-top: 5px;
    cursor: pointer;

#master_content .accordionHeaderSelected a {
    color: #FFFFFF;
    background: none;
    text-decoration: none;

    #master_content .accordionHeaderSelected a:hover {
        background: none;
        text-decoration: underline;

.accordionContent {
    background-color: #D3DEEF;
    border: 1px dashed #2F4F4F;
    border-top: none;
    padding: 5px;
    padding-top: 10px;

Now Run the Page again. Lets See, how it looked. Check this at your machine. Best of Luck!

File Upload Control with File Type Filter


We are going to learn how to upload a File using FileUpload Control in ASP.NET.

ASPX Code. We Placed a FileUpload Control and a button to Click.


Now BtnUpload_Click event in .cs page.

We are going to Upload only Picture (.JPG file or .BMP file).

 protected void BtnUpload_Click(object sender, EventArgs e)
        string sSiteFolder = "ResumeFolder";
        string sRealPath = Server.MapPath(sSiteFolder);
        if (!Directory.Exists(sRealPath))
     string CompletePath = sRealPath + FileUpload1.FileName;
        string FileExt = CompletePath.Substring(CompletePath.IndexOf("."));
        switch (FileExt)
            case ".jpg":
                FileUpload1.SaveAs(sRealPath + FileUpload1.FileName);
            case ".JPG":
                FileUpload1.SaveAs(sRealPath + FileUpload1.FileName);
            case ".bmp":
                FileUpload1.SaveAs(sRealPath + FileUpload1.FileName);
            case ".BMP":
                FileUpload1.SaveAs(sRealPath + FileUpload1.FileName);

John Bhatt

Support Help Nepal Network by Facebook.

A method to Pass Time and in its language utility to connect with World. There are more accounts on Facebook than the Polulation of Earth.

Friends, some one is willing to do good work using Facebook. You should support. Just one click to Support a will to do for the Nation. I think every body wants to do something for his nation. Its time to do something.

Lets Vote for Help Nepal Network on Chase Community Giving's Polling Competition.


Like application. and Vote.

Pagination with DataList

As we know, DataList is the most versatile Data Bound Control available in ASP.NET. Where you can display data as per your need in your required style, direction etc.
But there is some problem also. There is no option to Paginate the Data Loaded in DataList directly. In case we have too many records, we can not display all them in One Page without paginating.

To escape from this situation, Developers move to GridView, which has easy support for Paginating data.

Today, we will learn How to Paginate DataList data in Simple steps.

First create a DataList as per your requirement. I made like below which is quite simple.

Lets place Next and Previous Buttons for Navigation. Code for above design is below:

Code in ASPX Page (Design)
  <asp:DataList ID="DataList1" runat="server" Height="194px" Width="174px" 
            onupdatecommand="DataList1_UpdateCommand" DataKeyField="eno">
              <table width="450" border="2">
                    <th>Employee Name </th>
                    <th>Designation </th>
                    <th>Salary </th>
                        <asp:TextBox ID="txtEname" Text='<%#Eval("ename")%>' runat="server" />
                        <asp:TextBox ID="txtJOb" Text='<%#Eval("job")%>' runat="server" />
                        <asp:TextBox ID="txtSal" Text='<%#Eval("sal")%>' runat="server" />
                        <asp:LinkButton ID="lnk2" runat="server" Text="Update" CommandName ="Update" />
                        <asp:LinkButton ID="LinkButton1" runat="server" Text="Cancel"
                         CommandName ="Cancel" />
                        <asp:LinkButton ID="lnk1" CommandName="Edit"  Text="Edit !" runat="server" />
        <br />
    <table class="style1">
            <td class="style2">
                <asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">Next</asp:LinkButton>
                <asp:LinkButton ID="LinkButton3" runat="server" onclick="LinkButton3_Click">Previous</asp:LinkButton>

Now Lets to to Backend. ASPX.CS Page (Code Behind):

protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
CurrentPageIndex = 0;
int pg = 0;
void showData()
PagedDataSource pgd = new PagedDataSource();
SqlDataAdapter da = new SqlDataAdapter("select * from emp", "Data Source=.\\SQLDB;Database=Test1;Integrated Security=True");
DataSet ds = new DataSet();

pgd.DataSource = ds.Tables[0].DefaultView;
pgd.CurrentPageIndex = CurrentPageIndex ;
pgd.AllowPaging = true;
pgd.PageSize = 5;

LinkButton2.Enabled = !(pgd.IsLastPage);
LinkButton3.Enabled = !(pgd.IsFirstPage);

DataList1.DataSource = pgd;


protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
DataList1.EditItemIndex = e.Item.ItemIndex;
protected void DataList1_CancelCommand(object source, DataListCommandEventArgs e)
DataList1.EditItemIndex = -1;
protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)


public int CurrentPageIndex
if (ViewState["pg"] == null)
return 0;
return Convert.ToInt16(ViewState["pg"]);
ViewState["pg"] = value;

protected void LinkButton2_Click(object sender, EventArgs e) {
protected void LinkButton3_Click(object sender, EventArgs e)

Now Let me Describe things happened in above code:

Move to showData() function.

We created a new object of PagedDataSource. Paged data source as name stands clear, paginated data.

Now we wrote Query, Passed in Adapter, Filled DataSet which should be all clear, because it was Basic Task in ADO.NET. Now we gave it CurrentPageIndex. means where is page now.

For this, just look below to a class CurrentPageIndex which is returning value of CurentPageIndex =0 if page is beling Loaded. To check whether page is loaded or postback, we take help of ViewState. If ViewState["pg"] == null, On Page load this will be null because it is just being initiated. On Postback it will pass the Int value stored in it to CurrentPageIndex.

We set Pagination in PagedDataSource true and Define Page size of 5 records per page.

Now Passed PagedDataSource object as Datasource of Datalist.

Now Linkbutton click events, We increased and Decreased value of CurrentPageIndex.

Hope this must be helpful to you. In case of Any problem, correction in code and help, feel free to comment below.

John Bhatt

Glad to Know, Free to Share.....


Rich Text Editor with ASP.NET


As we know, ASP.NET lack a Control, that we need most, RichText Editor. 

If you are trying to create a application or website with Admin Panel or Blog or Forum Website or something such project for Web in ASP.NET platform, we need RickText Editor. 

To overcome from this, we can use Many open source JavaScript based editors, like Tiny MCE, FCKEditor, etc.


In this Article, we would learn how to Implement Free RichText Editor into ASP.NET website. We are using TinyMCE editor here.

We are using TinyMCE, which is One of most popular and Open Source project. Download latest version of TinyMCE from Download Page, and Extract the Zip File.

Browse the Extracted Location and go to ..\tinymce_3.5.6\tinymce\jscripts folder.

Now Copy the tinymce folder from above Location to your Solution in Visual Studio.

Add a Page where you want to Implement RichTextbox and Design the Page.

Now lets Move to Topic. How to Add TinyMCE in Page and Richtext box Control placed for Content of Blog in above sample.

Insert JavaScript file tiny_mce.js in Web Page and some also initialize this function.

This Code into head Section.

Note: You can so many settings, look in Samples and Help Doc of TinyMCE.

Now Run the Page. Look, how it looked.

Without any additional Practice, our TextBox with Multiline turned into RichText Editor.

Now, its ok as per Requirement. No, when you will send Command to Server, it will return Error Like below.

We have to add just One Line of Code in Web.config file and one property in Default.aspx form (Page with Rich Text Editor).

That is : 

in web.config:


and in Page directive:

ValidateRequest = "false"
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" ValidateRequest="false" %>

Now, you can save the Data in Database, Do postback, retrieve same in Rich Text box and do anything you want.


IT is Jugad. So enything is possible here. Don't be worry about things that are not available. Just modify and make use of things those are available. Tiny MCE is one of the most known and Popular Rich Text editor (WYSIWYG).

This blog has been also posted on DotNetSpider at below Link Resources > http://www.dotnetspider.com/resources/44246-RichText-Editor-Integration-ASP-NET.aspx
Hope this will be helpful to you.

Implement Same WebMethod for AutoComplete in Multiple Textbox


While Answering a question at Forum, I wrote this post.

Suppose We have Multiple Textbox in Same Page and we want to Implement AutoSuggest/AutoComplete feature in All Textbox and of same type. Suppose Multiple Google Search Boxes.

For that case, we have separate Textboxs, Separate AutoComplete Extenders and Separate Methods. We are trying to Consume same PageMethod in All Textbox.

Front End Code:

Product One:

Product Two:

Product Three:

BackEnd Code:

[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    public static string[] GetProducts(string prefixText, int count, string contextKey)
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConToStore"].ConnectionString);
        SqlDataAdapter adp = new SqlDataAdapter("Select * from Products where UnitsInStock>0 and ProductName like '%" + prefixText + "%'", con);
        DataSet ds = new DataSet();
        string[] Products = new string[ds.Tables[0].Rows.Count];
        for (int j = 0; j <= ds.Tables[0].Rows.Count - 1; j++)
            Products.SetValue(ds.Tables[0].Rows[j][1].ToString(), j);
        return Products;
Lets Look at the Output.

Hope this will be Helpful.
John Bhatt
Glad to Know, Free to Share.....

DropDownList (Country-State-District-City)

How to Make a Complete Dropdown and Prevent Inserting Dummy Data from Form.
Disable other Controls when Clicked back to Parent Control:
Drop Down Sequence:
Load Country
Load State according to Country
Load Dists in State
List Cities in Dist.

protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
        ddlState.DataSource = res.States(Convert.ToInt16(ddlCountry.SelectedValue));
        ddlState.DataTextField = "StateName";
        ddlState.DataValueField = "StateID";
        ddlState.Items.Insert(0, "Select");
        ddlDist.Enabled = false;
        ddlCity.Enabled = false;

    protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
        ddlDist.DataSource = res.Districts(Convert.ToInt16(ddlState.SelectedValue));
        ddlDist.DataTextField = "DistName";
        ddlDist.DataValueField = "DistID";
        ddlDist.Items.Insert(0, "Select");
        ddlDist.Enabled = true;
        ddlCity.Enabled = false;

    protected void ddlDist_SelectedIndexChanged(object sender, EventArgs e)
        ddlCity.DataSource = res.Cities(Convert.ToInt16(ddlDist.SelectedValue));
        ddlCity.DataTextField = "CityName";
        ddlCity.DataValueField = "CityID";
        ddlCity.Items.Insert(0, "Select");
        ddlCity.Enabled = true;
John Bhatt
Glad to Know, Free to Share.....

Release Date of Windows 8


We are waiting for you so long, I think you are also waiting for... 

I am talking about Release Date of Upcoming Version of Windows. Worlds Most popular Operating System is now back with a Bang and Performance, Feature, Speed and Security Rich (Richer than MS), Windows 8.

What We Waited and When we received Publicly:

Developer Preview on : September 13, 2011

Consumer Preview on : On 29 February 2012

Release Preview on : May 31, 2012

And Now the Official announcement of Release Date of Windows 8.

Going to Buy on the First day and you........

Installing ASP.NET in IIS

Today we will learn how to Install .NET in IIS.
By default IIS is turned Off. To Turn on we will go to Control panel > programs > turn windows feature on or off.

Check all options by Expanding and Make sure that you got the Internet Information Services checked fully as in Above screen. Then you need not to install any more scripts to host asp.net websites.

Now If ASP.NET Websites are not running and throwing error like

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

Module StaticFileModule
Notification ExecuteRequestHandler
Handler StaticFile
Error Code 0x80070032
Requested URL http://localhost:80/JOHNSAPP/DEFAULT.ASPX
Physical Path C:\inetpub\wwwroot\John\Default.aspx
You should Install ASP.NET (configure IIS for ASP.NET).

Here are some basic steps to do so,
Open Command Prompt as Administrator
Navigate to C:\
C:\>cd Windows

C:\Windows>cd Microsoft.NET

C:\Windows\Microsoft.NET>cd Framework

Now you will be at


First Decide what version are you using. ASP.NET 1.0, 1.1, 2.0, 3, 3.5 , 4 or 4.5 (if Installed).
Then type following code in Command Prompt
C:\Windows\Microsoft.NET\Framework>cd v4.*      //installing ASP.NET V4.0 here.

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -i

 Command Prompt will Install Code and You are now Ready to Access your ASP.NET Site with Localhost.

Best of Luck....
John Bhatt

4 Years of Being Far From Family

I am going to write a blog about me, It's neither about Tech nor any other Courses. Its personal.

On the 13th of July 2008, I left my family to work. I've just gave Exams of +2 and worried about Exams. So I decided to go to India and do some job between the time period of Exams and Results. I have done a Basic Computer Course called SOP (Smart Office Professional) from UNIT-IT, then I did a crash course from Modern Computer Institute which took about 2 months.

When I left home, I expected a Basic average salary (about 5K INR), working with Computers, a Good office and blah blah...

I, a friend from Village Jagdish and my and Brother (in family relations) left home at the afternoon of 13th July which I still remember. Next Day morning , 14th July 2008, I was working with a Transportation Company named BEST ROADWAYS LIMITED. I was First time in India for permanent living and directly in Haryana. The Language of Haryana is some hard to hear and direct hits ear (but they are really nice). Slowly slowly I adjusted myself with atmosphere.

Now Summary of things what I think I got after leaving home.

  1. Experience of Work / Job.
  2. Completed my +2
  3. Pursuing Graduation
  4. DOEACC 'A' Level
  5. .NET Training / Web Development & Design
  6. Wide Experience in Computer Programming
  7. Some Good Friends
  8. Deep Introduction of Human Nature at Job.
  9. And Most Important.- A Loving and Caring Family 
My biggest earning which  I think is faith and believe of some people which can never be bought.

I can not describe the Joy of listening these Words. 'परदेश में होकर भी अपने  परिवार से ज्यादा प्यार करने वाले परिवार पाने वाले तुम्हे देखकर मुझे जलन होती है | '.

Thanks and Congratulations....

Just Got the 10,000th Visitor to make my blog hits..

Many many Thanks and Congratulations......

State Management in ASP.NET part-1 (Cookies)


I am Back with State Management Series.

In this post we are going to Talk about Cookies. After Reading this, you must be able to do following things:
  • Create Cookie
  • Access Cookie
  • Can answer Some Basic Q & A about Cookie
What is Need of Cookie?

Cookies are Required to Store Temporary data in Users system which may be Required during Session or after Session.

How Many Type of Cookie are there?
Cookies are generally of Two Type. Session wide or Persistent. Sessional cookies Expire as soon as User Closed Session means Browser. Persistent cookies expire after Defined Time. This can be Defined at the Time of Creation.

Who Make Cookies?

Cookie is always made by Application (Server) in Users/ Clients Browser and stored in Hard Disk of User. These are used to store Users Customized Appearance, other Values , Login Time etc for future Retrieval so that website can server him better.

Limitations of Cookie?

Cookies are open Invitations to Hackers.

Cookies can only store Little and Only String Type Data.

Now Lets Learn with Coding. First We will Create a Cookie named myCookie and Solve Earlier Problem with the Help of Cookie.
Now Code is Like Below:
protected void Page_Load(object sender, EventArgs e)

    int x;    // Made a Variable with Datatype Int for Future Use
    HttpCookie myCookie;   // Defined a Cookie named myCookie.
    protected void Button1_Click(object sender, EventArgs e)
        x = Convert.ToInt32(TextBox1.Text);  // Converted textbox Value which we earlier Did.
        myCookie = new HttpCookie("txtValue");  // Assigned Variable myCookie.
        myCookie.Value = Convert.ToString(x);   // Value assigned to myCookie.
        Response.Cookies.Add(myCookie); //This Simple Made a Cookie that will Expire in Session End.
        myCookie.Expires = DateTime.Now.AddMinutes(15);  // We made is Persistent and stored it for Next 15 minutes.
    protected void Button2_Click(object sender, EventArgs e)
        HttpCookie storedCook = Request.Cookies["txtValue"];  // Requested from Server for Cookie
        if (storedCook != null)  
            x = Convert.ToInt32(storedCook.Value);  // Converted to Integer again.
        TextBox1.Text = Convert.ToString(x * x);    // Now Printed Value in Textbox.
Now Check....

Don't forget to add me on Google+, +John Bhatt .

State Management in ASP.NET

Hi Everybody,

I am once back with a blog/article/tutorial whatever you think/call it.

State Management :

HTTP Protocol is State less protocol. In Simple Language, Each and Every time We send a request to server, this is New to server.

To Understand this ,Suppose you took One Textbox and Two Buttons like in Image below:

Now, the task is To Enter Number in Textbox and Click in First Button to Convert to Integer format and then Click Second button to Print Square of Converted Integer in Textbox. What will you do. Lets look at code what I did here.

protected void Page_Load(object sender, EventArgs e)

    int x;

    protected void Button1_Click(object sender, EventArgs e)
        x = Convert.ToInt32(TextBox1.Text);
    protected void Button2_Click(object sender, EventArgs e)
        TextBox1.Text = Convert.ToString(x * x);

Now what would I get Result on Second Button Click event. Textbox Result will be 0 even I have entered any number. Don't agree, try this at home.

This is Because, at the time of Button2 Click new request is send to server and Initial Value of X is picked from server which is 0.

To Prevent the Loose of Data each time we send request to server, ASP.NET have implemented concept of State Management.

State Management is divided into 2 parts according to Functionality.

1) User Based State Management
  • Cookies
  • QueryStrings
  • ViewState
  • Controls
  • Hidden Fields
2) Server Based State Management
  • Session
  • Application
  • Profile

I am going to Describe all these States step by step in Different Posts.

All the Series has been posted on DotNetSpider at below Link Resources > Keep Reading.

AutoCompleteExtender in Textbox


We will learn how to enable AutoCompleteExtender in Textbox Control.

Here, We will learn to Map data from SQL Database to Textbox within Same Page. WebMethod in .cs Page.

Directly to Code:
ASPX Page Code

Vehicle No :

Now Code in ASPX.CS Page

Add these Namespages for below Code.
using System.Data; // For Dataset
using System.Data.SqlClient; // For SQlConnection/Adaptor
using System.Configuration; // Access Consting from Web.Config.
using System.Collections.Generic; 

[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    public static string[] GetVehicleList(string prefixText, int count, string contextKey)
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConToJohn"].ConnectionString);
        SqlDataAdapter adp = new SqlDataAdapter("Select distinct VehicleNo from VehicleDispatch where VehicleNo like '%" + prefixText + "%'", con);
        DataSet ds = new DataSet();
        adp.Fill(ds, "Vehicles");
        string[] VehicleNo = new string[ds.Tables["Vehicles"].Rows.Count];
        for (int i = 0; i <= ds.Tables["Vehicles"].Rows.Count - 1; i++)
            VehicleNo.SetValue(ds.Tables["Vehicles"].Rows[0][0].ToString(), i);
   return VehicleNo;
I have Selected Only Unique Value from Database using SELECT DISTINCT .... command. If you want all records, Simply Change SQL Query to SELECT ..... Will be glad to hear from you... This Post is copied from DotNetFunda where I wrote in Code section.

Opening a Webpage according to Textbox Value


Today I am going to tell you, how to Open a Web Page according to TextBox Value in ASP.NET. You can implement same in Plain HTML Page. This will use a Simple JavaScript Function which we will create according to our need.
Lets Look at the Code. We are using ASP.NET Ajax AutoCompleteExtender for more enhancement in Code (This will only work in ASP.NET).
Code for ASPX Page (HTML Design Part - ASP.NET)



If you are using Plain HTML, Just use this code.

Now JavaScript Code which is Inserted Directly in Head Section. (JavaScript)

Now code for C# page if you are using AutoComplete Extender.
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]

    public static string[] GetCompletionList(string prefixText, int count, string contextKey)


        string[] Brands = { "hp", "acer", "dell", "lenovo" };

        return (from m in Brands where m.StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase) select m).Take(count).ToArray();  


Export to Excel from DataGridView in ASP.NET

We are going to learn how to Export GridView data to Microsoft Excel at Runtime.

We are using: ASP.NET Framework 4.0, Visual Studio 2010, SQL Server 2008, C#, XHTML 4.01

 Code for ASPX Page (Front-End) Adding GridView and Columns:



















































Adding Export Link



Now Code for ASPX.CS Page (BackEnd):

Namespaces :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing;
using System.IO;
using System.Text;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;

BindGridView Function
void GVProsFill()


        string Query = "Select * from Parties,  Prosperity where Parties.PartyID=Prosperity.ProParty";

        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConToMyDB"].ConnectionString);

        SqlDataAdapter adp = new SqlDataAdapter(Query, con);

        DataSet ds = new DataSet();


        gvPros.DataSource = ds.Tables[0];



Export LinkButton Click Event:
//You have to add an another Event for Export to work properly:

public override void VerifyRenderingInServerForm(Control control) 


         // Can Leave This Blank. 


protected void lnkExport_Click(object sender, EventArgs e)



        Response.Buffer = true;

        Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Prosperity.xls"));

        Response.ContentType = "application/ms-excel";

        StringWriter sw = new StringWriter();

        HtmlTextWriter htw = new HtmlTextWriter(sw);

        gvPros.AllowPaging = false;


        gvPros.HeaderRow.Style.Add("background-color", "#FFFFFF");

        for (int i = 0; i < gvPros.HeaderRow.Cells.Count; i++)


            gvPros.HeaderRow.Cells.Style.Add("background-color", "#507CD1");


        int j = 1;

        foreach (GridViewRow gvrow in gvPros.Rows)


            gvrow.BackColor = Color.White;

            if (j <= gvPros.Rows.Count)


        if (j % 2 != 0)


        for (int k = 0; k < gvrow.Cells.Count; k++)


            gvrow.Cells[k].Style.Add("background-color", "#EFF3FB");









I will be waiting to Listen from you....

Microsoft Excel 2003 : File Menu and Its Commands

Hello Friends,
I am Back with Excel Tutorial Series. Lets Start with File Menu and Its Commands....

1) New (Ctrl+N) : 

As in earlier software we learned, New works same. When clicked New in File menu you will get New option in Task Pane and you have following options to choose:
Blank Workbook
From Existing Workbook….
As I told earlier, MS-Excel’s document is known as Workbook. Choose Blank Workbook to create one.
Shortcut Key for New Blank Workbook is CTRL+N (^N).

2) Open (Ctrl+O) :

This option is used to Open previously saved Workbook for Viewing, Editing, Printing or Analyzing.
Shortcut for this option is CTRL+O.  Here is Open Dialogue Box.

3) Close :

This command is used to close current workbook. You can close your file without exiting from program. 
When clicked Close it prompts you to save workbook if it is not saved yet. 
Shortcut for this option is CTRL+W.

4) Save (Ctrl+S) :

This option saves current active workbook. 
If it is being saved first time it displays Save As Dialogue Box and gives you option to choose location, give name of workbook and Set File Format else it updates current workbook. 
Shortcut for this command is CTRL+S. Here is a Save As Dialogue Box.

5) Save As :

This command displays Save As dialogue box each and every time you click/choose this option. Even your workbook is Already saved, you will get Save As dialogue box to save your file with other name, at other location or with another format/extension. This command is also a very popular and useful command for Excel. 
Shortcut Key for this option is F12.

6) Save As Web Page :

This command saves current workbook as Web Page so that it can be published on the web. You have options to choose which sheet you want to publish, Add interactivity, etc. Whenever clicked this option, save as dialogue box appears with some modification. Such as Change Title and other option.

7) Save Workspace ;

A Document Workspace site is a Microsoft Windows Share Point Services site that is centered around one or more documents. You and your friend can work on same Workbook at same time at Workspace and update the individual work at final stage.
So this is very good feature of MS-Excel that makes work easy and friendly in Networking.

8) File Search : 

This option is used to search Files or File Contents. This is same as File or Folder Search option in Start Menu. But you can search only such documents which are supported by MS-Excel. You have feature to choose location and File Type on Task Pane when this option is chosen.

9) Permissions :

You can create workbook with restrictions only if you have installed Professional version of Microsoft Office 2003.
This feature works on MS-Word, MS-Excel, MS-PowerPoint or MS-Excess only if Information Right Management feature is added to your software.
This feature manages to whom you allow to make change or share your file.

10) Web Page Preview:

This option shows the workbook in browser how it would look like after publishing. If you have created your document for Web Page purpose you can experience the high quality fun of creating web pages. The temporarily converted webpage is stored in temporary folder in .mht and final output file is in .html format.

Remaining Options will be completed soon. Thanks for Patient. 

Shortcuts in Microsoft Excel 2003

Some Basic and Important Shortcuts.

     Short Key                                          Function
Tab or  Key (Right Arrow)           Move One Cell Right.
Shift + Tab or  (Left Arrow)         Move One Cell Left.
Enter or  Key  (Down Arrow)      Move One Cell down.
Shift + Enter or  (Up Arrow)       Move one Cell up.
Page Up                                          One Screen Up.
Page Down                                     One Screen Down.
Alt + Page Up                                One Screen Left
Alt + Page Down                           One Screen Right
Ctrl + Page Up                               Move Worksheet Left
Ctrl + Page Down                          Move Worksheet Right
Ctrl + End                                      Last Active Cell
Ctrl + Home                                  First Active Cell
Ctrl +    (Right Arrow)              Last Column of Workbook
Ctrl +     (Left Arrow)               First Column of Workbook
Ctrl +     (Down Arrow)            Last Row of Workbook
Ctrl +      (Up Arrow)               First Row of Workbook

How to Close Microsoft Excel  2003.

You can close Microsoft Excel in following ways:
  • Click on Lower Close button located below the Title Bar’s Close button. Doing this will prompt you top save document if it is not saved yet. Then Click on Close Button of Title Bar.
  • Right Click on File Name in Task Bar and choose  Close option. Microsoft Excel will prompt you to save document if it is unsaved.
  • Click on ALT+F4 key directly from Keyboard. Microsoft Excel will prompt you to save document if it is unsaved.