Tuesday, September 24, 2013

How To Validate TextBox using jQuery Block Unwanted Characters

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

Thanks

Monday, September 16, 2013

HOW TO CONFIGURE VIRTUAL PC AND INSTALL WINDOWS

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