Tuesday, September 30, 2014

How To Disable Checkbox using JavaScript

To Disable HTML checkbox using javascript use the following script

document.getElementById("chkRed").disabled = true;

To Enable change true to false

document.getElementById("chkRed").disabled = false;

where chkRed is the id of your Checkbox

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

Monday, September 29, 2014

How to bind Asp DropDownList Value and text

In order to bind Asp DropDownList value and text field use the following method

lets day DroDownList id is "ddl"

 List<taqi> objlist = new List<taqi>();
                taqi objt = new taqi();
                objt.Id = "2";
                objt.Name = "Taqi";
                objlist.Add(objt);   // adding item in list

                objt = new taqi();
                objt.Id = "1";
                objt.Name = "Ali";
                objlist.Add(objt);   // adding item in list
                                             // so we have added two items in list now we will bind dropdownlist

                ddl.DataSource = objlist;  
                ddl.DataTextField = "Name";    //Name field is define in the class called taqi
                ddl.DataValueField = "Id";        // Id field is define in the class called taqi
                ddl.DataBind();                        // finally we bind the dropdownlist

For your convenience here is the class source code

  public class taqi
    {

        private string id;

        public string Id
        {
            get { return id; }
            set { id = value; }
        }

        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
    }

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

 

Sunday, September 28, 2014

Visual Studio Shortcuts

  • To Comment Out a Line or a section of code
                   Ctrl + E + C
  • To Un-Comment a Line or a section of code
                  Ctrl + E + U
  • To find the matching bracket
                  Ctrl + ]
  • To Collapse Current Line
                
  • Add missing namespace
                   Ctrl + .

Friday, September 12, 2014

Restrict Numbers from being entered in Textbox using jQuery

How to restrict user from entering Numbers (0-9) inside textbox Field

 $("#TextBoxID").keypress(function (e) {
               
                if (e.which >= 65 && e.which <= 90 || e.which >= 97 && e.which <= 122) {

                }
                else return false;
            });

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

Tuesday, September 2, 2014

How to create JaggedArray in C#

A Jagged Array is an Array of Array
   string[][] Arr = new string[3][];
            
            Arr[0] = new string[3];
            Arr[1] = new string[2];
            Arr[2] = new string[1];

            Arr[0][0] = "Bachelor";
            Arr[0][1] = "Masters";
            Arr[0][2] = "PHD";

            Arr[1][0] = "Bachelor 1";
            Arr[1][1] = "Masters  1";

            foreach (string[] b in Arr)
            {
                foreach (string a in b)
                {
                    Console.WriteLine(a);
                }
            }

            Console.ReadKey();


            // we can also create a JaggedArray of type object 

            object[][] arr2 = new object[3][];

            arr2[0] = new object[3];
            arr2[0][0] = 1;
            arr2[0][1] = "String";
            arr2[0][2] = Arr;
 
I Hope it was informative for you and I would like to Thank you for reading