Happy New Year 2013...


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

Reactions: 

Run Commands Listed In Alphabetical Order

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

Program
Run Command
Accessibility Controls
access.cpl
Accessibility Wizard
accwiz
Add Hardware Wizard
hdwwiz.cpl
Add/Remove Programs
appwiz.cpl
Administrative Tools
control admintools
Adobe Acrobat ( if installed )
acrobat
Adobe Distiller ( if installed )
acrodist
Adobe ImageReady ( if installed )
imageready
Adobe Photoshop ( if installed )
photoshop
Automatic Updates
wuaucpl.cpl
Basic Media Player
mplay32
Bluetooth Transfer Wizard
fsquirt
Calculator
calc
Ccleaner ( if installed )
ccleaner
C: Drive
c:
Certificate Manager
cdrtmgr.msc
Character Map
charmap
Check Disk Utility
chkdsk
Clipboard Viewer
clipbrd
Command Prompt
cmd
Command Prompt
command
Component Services
dcomcnfg
Computer Management
compmgmt.msc
Compare Files
comp
Control Panel
control
Create a shared folder Wizard
shrpubw
Date and Time Properties
timedate.cpl
DDE Shares
ddeshare
Device Manager
devmgmt.msc
Direct X Control Panel ( if installed )
directx.cpl
Direct X Troubleshooter
dxdiag
Disk Cleanup Utility
cleanmgr
Disk Defragment
dfrg.msc
Disk Partition Manager
diskmgmt.msc
Display Properties
control desktop
Display Properties
desk.cpl
Display Properties (w/Appearance Tab Preselected )
control color
Dr. Watson System Troubleshooting Utility
drwtsn32
Driver Verifier Utility
verifier
Ethereal ( if installed )
ethereal
Event Viewer
eventvwr.msc
Files and Settings Transfer Tool
migwiz
File Signature Verification Tool
sigverif
Findfast
findfast.cpl
Firefox
firefox
Folders Properties
control folders
Fonts
fonts
Fonts Folder
fonts
Free Cell Card Game
freecell
Game Controllers
joy.cpl
Group Policy Editor ( xp pro )
gpedit.msc
Hearts Card Game
mshearts
Help and Support
helpctr
Hyperterminal
hypertrm
Hotline Client
hotlineclient
Iexpress Wizard
iexpress
Indexing Service
ciadv.msc
Internet Connection Wizard
icwonn1
Internet Properties
inetcpl.cpl
Internet Setup Wizard
inetwiz
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 )
jpicpl32.cpl
Java Control Panel ( if installed )
javaws
Keyboard Properties
control keyboard
Local Security Settings
secpol.msc
Local Users and Groups
lusrmgr.msc
Logs You Out of Windows
logoff
Malicious Software Removal Tool
mrt
Microsoft Access ( if installed )
access.cpl
Microsoft Chat
winchat
Microsoft Excel ( if installed )
excel
Microsoft Diskpart
diskpart
Microsoft Frontpage ( if installed )
frontpg
Microsoft Movie Maker
moviemk
Microsoft Management Console
mmc
Microsoft Narrator
narrator
Microsoft Paint
mspaint
Microsoft Powerpoint
powerpnt
Microsoft Word ( if installed )
winword
Microsoft Syncronization Tool
mobsync
Minesweeper Game
winmine
Mouse Properties
control mouse
Mouse Properties
main.cpl
MS-Dos Editor
edit
MS-Dos FTP
ftp

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

Reactions: 

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:
comboBox2.Items.Clear();
                   if (checkBox1.Checked == true)
                   {
                       ConStr = "Data Source = " + comboBox1.Text.ToString() + ";Integrated Security = true;";
                   }
                   else
                   {
                       ConStr = "Data Source = " + comboBox1.Text.ToString() + ";UID=" + textBox1.Text + ";pwd=" + textBox2.Text + ";";
                   }
                   SqlConnection Conexion = new SqlConnection(ConStr);
                   Conexion.Open();
                   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++)
                   {
                       comboBox2.Items.Add(tblDatabases.Rows[i][0].ToString());
                   }
                   Conexion.Close();

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)
        {
            comboBox3.Items.Clear();
            SqlConnection conx = new SqlConnection(ConStr + "Database ="+comboBox2.Text.ToString()+";");
            conx.Open();
            DataTable tblTables = conx.GetSchema("Tables");
            for (int i = 0; i <= tblTables.Rows.Count - 1; i++)
            {
                comboBox3.Items.Add(tblTables.Rows[i][2].ToString());
            }
            conx.Close();
        }
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)
        {
            comboBox4.Items.Clear();
            SqlConnection conx = new SqlConnection(ConStr + "Database =" + comboBox2.Text.ToString() + ";");
            conx.Open();
            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();
            adp.Fill(tblColumns);
            for (int i = 0; i <= tblColumns.Rows.Count - 1; i++)
            {
                comboBox4.Items.Add(tblColumns.Rows[i][3].ToString());
            }
            conx.Close();
        }

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 + "%'";
            }
            else
            {
                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();
            adp.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0];
        }

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

Reactions: 

List All SQL Server Instances in Combo (Windows Form)


Hi,

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++)
            {
                comboBox1.Items.Add(SerNames.Rows[i][0].ToString()+"\\"+SerNames.Rows[i][1].ToString());
            }
        }

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);
            }
            else
            {
                errorProvider1.Clear();
                if (MessageBox.Show("Connection Successfull!, You are Now Connected to Server: " + comboBox1.Text.ToString() + "!", this.Text + " - Alert", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                {
                    comboBox2.Items.Clear();
                    if (checkBox1.Checked == true)
                    {
                        ConStr = "Data Source = " + comboBox1.Text.ToString() + ";Integrated Security = true;";
                    }
                    else
                    {
                        ConStr = "Data Source = " + comboBox1.Text.ToString() + ";UID=" + textBox1.Text + ";pwd=" + textBox2.Text + ";";
                    }
                    SqlConnection Conexion = new SqlConnection(ConStr);
                    Conexion.Open();
                    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++)
                    {
                        comboBox2.Items.Add(tblDatabases.Rows[i][0].ToString());
                    }
                    Conexion.Close();
                }
            }
        }

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.....

Reactions: 
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" />--%>
</head>

<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <table width="100%" border="0">
            <tr>
                <td colspan="2" align="center">
                    <h1>Accordian with CSS</h1>
                </td>
            </tr>
            <tr>
                <td colspan="3" align="center">
                    <asp:Accordion ID="Accordion1" runat="server" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" Width="490px">
                        <Panes>
                            <asp:AccordionPane ID="pane1" runat="server">
                                <Header>Hardwares</Header>
                                <Content>
                                    Mouse<br />
                                    KeyBoard<br />
                                    Monitor
                                    <br />
                                    Printer<br />
                                    CPU<br />
                                    Speakers<br />
                                    Camera
                                </Content>
                            </asp:AccordionPane>
                            <asp:AccordionPane ID="pane2" runat="server">
                                <Header>Operating System</Header>
                                <Content>
                                    MS Windows<br />
                                    Linux<br />
                                    Android<br />
                                    Mac<br />
                                    Unix
                                </Content>
                            </asp:AccordionPane>
                            <asp:AccordionPane ID="pane3" runat="server">
                                <Header>.NET IDE</Header>
                                <Content>
                                    Visual Studio<br />
                                    Visual Web Developer<br />
                                    SharpDevelop<br />
                                    MonoDevelop
                                </Content>
                            </asp:AccordionPane>
                            <asp:AccordionPane ID="pane4" runat="server">
                                <Header>John Bhatt</Header>
                                <Content>
                                    <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 />
                                </Content>
                            </asp:AccordionPane>
                        </Panes>
                    </asp:Accordion>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>


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!

Reactions: 

File Upload Control with File Type Filter

Hi,


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))
            Directory.CreateDirectory(sRealPath);
     string CompletePath = sRealPath + FileUpload1.FileName;
        string FileExt = CompletePath.Substring(CompletePath.IndexOf("."));
        switch (FileExt)
        {
            case ".jpg":
                FileUpload1.SaveAs(sRealPath + FileUpload1.FileName);
                break;
            case ".JPG":
                FileUpload1.SaveAs(sRealPath + FileUpload1.FileName);
                break;
            case ".bmp":
                FileUpload1.SaveAs(sRealPath + FileUpload1.FileName);
                break;
            case ".BMP":
                FileUpload1.SaveAs(sRealPath + FileUpload1.FileName);
                break;
        }
    }
Enjoy...

John Bhatt

Reactions: 

Support Help Nepal Network by Facebook.

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.

http://apps.facebook.com/chasecommunitygiving/charity/view/ein/51-0496452


Like application. and Vote.

Reactions: 

Pagination with DataList

Hi,
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" 
            oneditcommand="DataList1_EditCommand" 
            oncancelcommand="DataList1_CancelCommand" 
            onupdatecommand="DataList1_UpdateCommand" DataKeyField="eno">
            <HeaderTemplate>
              
              <table width="450" border="2">
                <tr>
                    <th>Employee Name </th>
                    <th>Designation </th>
                    <th>Salary </th>
                    <th>
                        Edit
                    </th>
                </tr>
               
            </HeaderTemplate> 
            <EditItemTemplate>
                <tr>
                    <td>
                        <asp:TextBox ID="txtEname" Text='<%#Eval("ename")%>' runat="server" />
                    </td>
                    <td>
                        <asp:TextBox ID="txtJOb" Text='<%#Eval("job")%>' runat="server" />
                    </td>
                    <td>
                        <asp:TextBox ID="txtSal" Text='<%#Eval("sal")%>' runat="server" />
                    </td>
                    <td>
                        <asp:LinkButton ID="lnk2" runat="server" Text="Update" CommandName ="Update" />
                    </td>
                    <td>
                        <asp:LinkButton ID="LinkButton1" runat="server" Text="Cancel"
                         CommandName ="Cancel" />
                    </td>
                </tr>
            
            </EditItemTemplate> 
            <ItemTemplate>
                <tr>
                    <td><%#Eval("ename")%></td>
                    <td><%#Eval("job")%></td>
                    <td><%#Eval("sal")%></td>
                    <td>
                        <asp:LinkButton ID="lnk1" CommandName="Edit"  Text="Edit !" runat="server" />
                    </td>
                </tr>
                
            </ItemTemplate> 
            
            <FooterTemplate>
              </table>
            </FooterTemplate> 
        </asp:DataList>
        <br />
    <table class="style1">
        <tr>
            <td class="style2">
                <asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">Next</asp:LinkButton>
            </td>
            <td>
                <asp:LinkButton ID="LinkButton3" runat="server" onclick="LinkButton3_Click">Previous</asp:LinkButton>
            </td>
        </tr>
    </table> 




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





protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CurrentPageIndex = 0;
showData();
}
}
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();
da.Fill(ds);

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;
DataList1.DataBind();

}

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

}

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

protected void LinkButton2_Click(object sender, EventArgs e) {
CurrentPageIndex++;
showData();
}
protected void LinkButton3_Click(object sender, EventArgs e)
{
CurrentPageIndex--;
showData();
}




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.....





http://www.johnbhatt.com





Reactions: 

Rich Text Editor with ASP.NET


Introduction


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.

Content:

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.

Conclusion


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.

Reactions: 

Implement Same WebMethod for AutoComplete in Multiple Textbox

Hi,


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();
        adp.Fill(ds);
        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.....
http://www.johnbhatt.com

Reactions: 

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:
OnLoad
Load Country
On-Change
Load State according to Country
On-Change
Load Dists in State
On-Change
List Cities in Dist.

Code:
protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
    {
        ddlState.DataSource = res.States(Convert.ToInt16(ddlCountry.SelectedValue));
        ddlState.DataTextField = "StateName";
        ddlState.DataValueField = "StateID";
        ddlState.DataBind();
        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.DataBind();
        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.DataBind();
        ddlCity.Items.Insert(0, "Select");
        ddlCity.Enabled = true;
    }
John Bhatt
Glad to Know, Free to Share.....
http://www.johnbhatt.com

Reactions: 

Release Date of Windows 8

Hi,


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........

Reactions: 

Installing ASP.NET in IIS

Hi,
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

C:\Windows\Microsoft.NET\Framework\

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

Reactions: 

4 Years of Being Far From Family

Today,
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. 'परदेश में होकर भी अपने  परिवार से ज्यादा प्यार करने वाले परिवार पाने वाले तुम्हे देखकर मुझे जलन होती है | '.

Reactions: 

Thanks and Congratulations....

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

Many many Thanks and Congratulations......

Reactions: 

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

Hi,

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 .

Reactions: 

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.

Reactions: 

AutoCompleteExtender in Textbox

Hi,

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.

Reactions: 

Opening a Webpage according to Textbox Value

Hi,

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();  

    }
Enjoy...

Reactions: 

Export to Excel from DataGridView in ASP.NET

Hi,
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();

        adp.Fill(ds);

        gvPros.DataSource = ds.Tables[0];

        gvPros.DataBind();

    }


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.ClearContent();

        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;

        GVProsFill();

        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");

        }

        }

        }

        j++;

        }

        gvPros.RenderControl(htw);

        Response.Write(sw.ToString());

        Response.End();

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

Reactions: 

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. 

Reactions: 

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.

Reactions: