Tuesday, September 24, 2013

How To Validate TextBox using jQuery Block Unwanted Characters

         In jQuery you might want to limit the user to type either only numbers or characters. We can do this with jQuery very easily.

1. First create a TextBox set it's id="TextBox1"

   1:  <body>
   2:      <form id="form1" runat="server">
   3:      <div>
   4:          <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
   5:      </div>
   6:      </form>
   7:  </body>

2. Now we will write jQuery to stop user from entering numbers 0-9, i.e. user is only allowed to type Alphabets and some special characters

   1:      <script type="text/jscript">
   2:          $(document).ready(function () {
   3:              $("#TextBox1").keypress(function (e) {
   4:                  if (e.key >= 0 && e.key <= 9)
   5:                      return false;
   6:              });
   7:          });
   8:      </script>

We limit the user from entering numbers using keypress event

I hope it was informative for you and I would like to Thank you for reading

Friday, September 20, 2013

How To Use HiddenField in ASP

The HiddenField in ASP.Net give us the facility to store our information in the page without displaying it. i.e. we can get and set the value of hiddenfield but they will not appear on the page.

We can use HiddenField property both in Server Side and Client Side

Note: You should not store sensitive data in HiddenField because even though it is hidden it can still be access able by viewing the page source.

In this post I will show you how to use HiddenField.

In this example I will first change the HiddenField value on client Side using jQuery and than at server side we will access that value

   1:  <html xmlns="http://www.w3.org/1999/xhtml">
   2:  <head runat="server">
   3:      <title></title>
   4:      <script type="text/jscript" src="jquery-1.9.1.js"></script>
   5:      <script type="text/jscript">
   6:          $(document).ready(function () {
   7:              $("#hf1").val("Value Changed from Client Side");
   8:          });
   9:      </script>
  10:  </head>
  11:  <body>
  12:      <form id="form1" runat="server">
  13:      <div>
  14:          <asp:Button ID="btn1" runat="server" Text="Click on me" OnClick="btn1_Click" />
  15:          <br />
  16:          <asp:Label ID="lbl1" runat="server"></asp:Label>
  17:          <asp:HiddenField ID="hf1" runat="server" />
  18:      </div>
  19:      </form>
  20:  </body>
  21:  </html>

In the source I define a textbox, a HiddenField, and a Label and than using jQuery I change the value of HiddenField

Now we will try to access this value from Server Side

   1:  protected void btn1_Click(object sender, EventArgs e)
   2:          {
   3:              lbl1.Text = hf1.Value;
   4:          }

When the User click on the button the value of hiddenField will be stored in our Label

I hope this was informative for you and I would like to Thank you for reading

Digital Clock in C#

I have developed this Digital Clock in C#

You will require Framework 4.0 for this to run on your Computer

Download the Digital Clock Application from HERE

Download the source code from HERE, for password please leave a comment.


Monday, September 16, 2013


Hello every1,

               Today in this tutorial I'm gonna show you how can you configure Virtual Machine to create a Virtual Hard Disk, and than How to install windows on it

Things you will need

1. Microsoft Virtual PC Download from HERE

2. Bootable ISO of Any Windows Setup

Ok lets GO!

1. Open Microsoft Virtual PC

2. Click on the New button
(A wizard will popup )

3. Click On Next

4. Select Create a Virtual Machine and click on Next

5.  Now assign a name to your Virtual Machine file, you can also choose a path to store your virtual Machine to specific location by click on Browse button

6. Click On Next

7. Now select the operating system from DropDown list, which you will install in Virtual Machine, if your OS name doesn't exist than select Other

8. Now you will configure amount of RAM for Virtual Machine, you can either select the default settings, or select Adjust The Ram Radio Button, and click on Next

8. Now select A New Virtual Hard Disk, and click on Next

9. Now select the path to store you Virtual hard disk(.vhd), You can also set the Virtual hard disk size.

10. Click on Next, than Finish.

You have successfully created your Virtual Hard disk, Now you can install windows on this Hard disk.

To install Windows on this hard disk

1.  Double Click on the newly created Virtual Machine

A window will open which will be similar to above one

2. From menu bar click on CD, and than click on Capture ISO image

3. Now select the .iso file of your windows setup

4. From menu bar click on Action and than click on Reset
This will restart you Virtual Machine, and it will boot using the ISO image that you just provided.

I hope it was informative for you and I would like to Thank you for reading.

Monday, September 9, 2013

Find Selected CheckBoxes in CheckBoxList C# ASP.Net

Find selected Checkboxes in a checkboxlist is quite easy using the foreach loop

1. First Create a checkboxlist and assign it's id="chklist"

2. Insert some random data inside your checkboxlist

3. Now using the following C# code you can find the selected checkboxlist

   1:   string a = "";
   2:              foreach (ListItem ls in chklisk.Items)
   3:              {
   4:                  if (ls.Selected)
   5:                  {
   6:                      a = a + ls.Text;
   7:                  }
   8:              }
The purpose of this foreach loop is to iterate through all the checkbox, if any checkbox is found selected than it's text will be stored in a sting called a

I hope it was informative for you, and I would like to thank you for reading

How To Publish Web Service in Visual Studio

Hello folks
                Today Im going to show you how to make a web service in Visual Studio C#

1. So first make a new project of ASP.NET Web Service Application

2. Name the project and click on OK

3. Now you will be redirected to Service1.asmx.cs page

4. In this page there is 1 method already created name as HelloWorld()

5. You can either use this method OR you can create your own method here

6. Now right click on the project and click on Publish

7. Select Web Deploy as Publish Method

8. Now in the Service URL type the address where you want to publish the Web Service for local computer you can simple type localhost, to publish on remote computer you will require administrative rights.

9. In Site/Application type Default Web Site/WebService2

* where webservice2 is the name of your web service

10. Finally click on Publish

You have successfully published you web service

To be able to access this service from any application you will also need to publish this on IIS, click HERE to see how to do this


Saturday, September 7, 2013

Get TextBox value using jQuery

In this post I'm showing you how to get TextBox value and use them in jQuery

This method will work on both HTML control and ASP control

1. First we will define a TextBox assign it id="txt1"
<input type="text" id="txt1" /><br />
2. Now we will create a button, and assign it id="btnSubmit"
<input type="submit" value="Click" id="btnSubmit" />
3.Now we will write the required jQuery code so that when the user click on the button, we will get an alert of textbox Text

   1:  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"  
   2:      <script type="text/jscript">
   3:          $(document).ready(function () {
   4:              $("#btnSubmit").click(function () {
   5:                  alert($("#txt1").val());
   6:              });
   7:          });
   8:      </script>

Following is the sample
Type A Text and Click on Submit button

Wednesday, September 4, 2013

How To Read XML Data through Ajax in jQuery

         Today Im gonna show you how you can read data on XML file in jQuery via Ajax

I'm using Visual Studio 2010 as my text editor you can use any editor you like

1. Open up Visual Studio and create a new Empty Website project
2. Now right click on your project and add a XML file name it "XMLFile1.xml"
3. Now inside your XML file paste the following code & save it
<?xml version="1.0" encoding="utf-8" ?>

  <name>Muhammad Taqi</name>

  <name>Ali Raza</name>
  <designation>Software Engineer</designation>

  <name>Muhammad Sagheer</name>
  <designation>Electrical Engineer</designation>
Now we will have to create a new web page in which we will call XML data using via Ajax using jQuery

5. Now right click on your project and add a New Web Page, name it whatever you want

6. Now just after the closing braces of <title> paste the following code

   1:  <script type="text/jscript" src="Scripts/jquery-1.9.1.js"></script>
   2:      <script type="text/jscript">
   3:          $(document).ready(function () {
   4:              $.ajax({
   5:                  url: "xmlfile1.xml",
   7:                  dataType: "XML",
   9:                  type: "GET",
  11:                  success: FnSuccess,
  13:                  error: FnError,
  15:                  complete: FnComplete
  17:              })
  18:          });  // .load closing
  20:          function FnSuccess(result) {
  21:              var id = result.getElementsByTagName("id")[0];
  22:              var name = result.getElementsByTagName("name")[0];
  23:              var designation = result.getElementsByTagName("designation")[0];
  24:          }
  26:          function FnError(result) {
  27:              alert("Error " + result.statusText);
  28:          }
  30:          function FnComplete(result) {
  31:              alert("Operation has been completed " + result.status);
  32:          }
  33:      </script>
As you can see inside .Ajax method we have passed few parameters

URL This will be the url of your XML file

dataType We define what type of data do we expect in our case the returned data will of XML, if it's simple text we would have write text

type Here we can to define what method we are using either GET or POST

success Here we define a function called FnSuccess, this means if everything goes well than move to this function

error Here we define a function called FnError, this means if something goes wrong than move to this method

complete Here we define doesn't matter if operation is successful or not, when the request is completed than move to this method

You can download the completed project from HERE

I hope this was informative for you and I would like to thank you for reading

Monday, September 2, 2013

Advantages of Using a Server Side Technology

The following are the advantages of using Server-Side Technology 

  1. Allows you to run programming languages that are not supported by your browser
  2. Enable browser independent application, without using browser client side programming features suck as using Java applets , ActiveX components
  3. Can provide client with data that is reside only on server but not on client
  4. Page can load faster than with Client side such as Java applet or ActiveX components, because in the end you are actually downloading a page of HTML
  5. It also provide increased security, since your code can never be viewed on browser
With all these advantages it doesn't mean that we should always use Server side technology, for example the workload on your server will increase if your web site become popular and you will need to buy expensive hardware to full fill your viewers requirement, so in that case Client Side Technology will do the trick

Sunday, September 1, 2013

How to Publish Web Service In IIS

         In this post I will show you how to publish your web service in IIS so that users on other computer can access it.

In the previous tutorial I showed you how to publish web service in Visual Studio, If you don't know how to do that than please look at this POST first

1. Ok First open up IIS Manager
I'm using IIS version 6.1

2. Now on the left side expand Site Folder than Default Web Site

3. Here You will find a folder name as webservice2, this is the name of my web service, this might be different for you if you set your web service name something else.

4. Now right click on your web service and click on Convert to Application

5. A window will pop-up just leave everything as it as, and click on OK

Now You have successfully published you web service.