Sunday, November 30, 2014

How To Hide DIV using JavaScript

In order to hide Div or any other control use the following code

To Hide

document.getElementById("Div1").style.display = 'none';

To Show
  
document.getElementById("Div1").style.display = 'block';

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

Saturday, October 4, 2014

Clustered Index VS Non Clustered Index in SQL

Clustered Index

  1.  cluster Index determines the physical order of data in a table
  2.  Primary key automatically Create a Cluster Index
  3.  A table can only have 1 cluster index, but 1 cluster index can have multiple column
  4.  Int and nvarchar both can have clustered index but nvarchar should not have max
  5. Cluster indexes are faster than non Clustered Index because both index and data are on same table
How to create a Cluster index

     Create Clustered index [cluster-name]
     on tablename(ColumnName)
 

Non Clustered Index

  1. In a Non-Clustered Index the index is stored seperately
  2. Just like a book the index is stored at the first page and data is on the other page
  3. A table can contain more than 1 non clustered index
  4. non Cluster indexes are slower than Clustered Index because index and data are on different table
  5. Becuase non clustered index are stored in a seperate table they require additional disk space
How to create a Non-Cluster index

     Create nonclustered index [cluster-name]
     on tablename(ColumnName)

How to check if a tabel has index or not

Execute sp_helpindex [table-name]


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

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

Saturday, August 30, 2014

How to Add Default Constraints in SQL

Syntax:

create table [Table_Name] (
[Column_Name] [dataType] constraint [Constraint_Name]
Default [Default_Value]
)

The Following example show how to add constraints during table creation process

create table MyTable(
id int not null constraint ConstID
Default 1,
name nvarchar(20)
)

The Following example show how to add constraints after the table has been created

alter table MyTable
add constraint MyConst
Default 'Default Value' for name

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

Monday, August 25, 2014

Storing different types in An Array C#

In this tutorial I will show you how can we store different types in An Array using C#

            int[] arr = new int[3];
            arr[0] = 0;
            arr[1] = "String";   <----  Not Allowed because Array type in Int and we are storing String

Now in order to store different types we will need to make an Array of type Object, because all types are inherited from Object hence we can store any type in Array

            object[] OArr = new object[3];
            OArr[0] = 1;
            OArr[1] = "String";    //   <----- We can store string because Array type is Object

We can also stored Class object in this Array

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

Friday, July 4, 2014

SQL Difference between Where And Having Clause

  • WHERE clause can be used with Select, Insert and Update statements, whereas HAVING clause can only be used with the Select statement
  • WHERE filters rows before aggregation (GROUPING), where as HAVING filters group, after the aggregation are performed
  • Aggregate functions cannot be used in the WHERE clause, unless it is in a sub query contained in a HAVING clause, whereas, aggregate functions can be used in HAVING clause
I hope it was informative for you and I would like to thank you for reading

Thursday, June 26, 2014

Add Solution .wsp to SharePoint using PowerShell

In order to add Solution files "wsp" to Sharepoint using powershell, just follow the below steps

1. Open up you Sharepoint 2010 power shell

2. Now navigate to the folder where your wsp file exist

3. Now type the following command

 add-spsolution -literalpath [File Path]

Replace File Path with complete path to your .wsp like

add-spsolution -literalpath c:\calendarwebpart.wsp

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

Monday, June 23, 2014

Move Site Collection To Another Content DataBase using powershell

In this demo I will show you how you can move site collection from existing content database to new Content Database in power shelll

1. Open up your Share point power shell

2. Type the following command

move-spsite [Site Collection which you want to move] -destinationdatabase [New Location for Site Collection]

move-spsite http://taqi/sites/mysite -destinationdatabase newcbd2

You will be asked to confirmed your action just type 'y'

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

Sunday, June 15, 2014

HOW TO CHECK SHAREPOINT VERSION

In order to check Sharepoint Version like

  • Major
  • Miner
  • Build
  • Revision 
We Can find the above information by either using power Shell or via SharePoint Central Administration

To Find this in PowerShell type
  • (get-spfarm).buildversion

To find this in Central Administrator

  1. Login to Central Administration
  2. Under Upgrade and  Patch Management
  3. Click on Check Product and Patch installation Service
This will give you all details not only about SharePoint but other products like Office

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


 

Thursday, June 12, 2014

How to send arguments Using Query String C# ASP.NET

Hello,

Using Query String we can send data from one page to another page easy

In ASP.NET we can send query string from one page to another page like this

Response.Redirect("FinalPage.aspx?value=myvalue1");

If you need to send multiple values than it is also possible by separating each value by & sign like this

Response.Redirect("FinalPage.aspx?value1=200&value2=201");

Now at the receiving page we need to get these arguments to do this use the following code

string value1 = Request.QueryString["value1"]; 
string value2 = Request.QueryString["value2"];

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

Monday, June 2, 2014

Download Microsoft Filter Pack 2.0 64 bit

In order to install Sharepoint 2010 x64 it is necessary to install Microsoft Filter Pack 2.0

If you don't have Microsoft Filter Pack than You can download it from the following link

Download Microsoft Filter Pack 2.0 x64

The file is password protected, password is 'taqi' without quotes

Thanks

Create Regular Expression to accept only Alphabets

In this tutorial I will show you how to create a Regular Expression that will only contain Alphabets, I will also show how to edit the RE to accept other characters

The following regEx will only accept Alphabets

 re = /^[A-Za-z]+$/;

To Accept Alphabets + some other characters like /,.,, we can write regular expression like below

 re = /^[A-Za-z-/-,-.]+$/;



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

Monday, April 21, 2014

Update label by using jQuery

In this tutorial I will shou you how to change label by using jQuery

we will use jQuery.text() method for this purpose

$("#lblShareError").text("Your new Text");

where lblShareError is the name of our label

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

Clear Textbox text using jQuery

In this tutorial I will show you how you can clear textbox value in jQuery

                $("#<%=TextBoxName.ClientID %>").val("");

To do this is javascript we can use document.getElementById

 document.getElementById('txtFolderName").value = "";

if the control is inside master page and you want to access it  from content page than use the following syntax

document.getElementById('<%=Master.FindControl("txtFolderName").ClientID %>').value = "";


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

Sunday, April 20, 2014

Check String length jQuery Custom Validation

In this tutorial I will show you how you can validate string length i.e. maximum and minimum characters in jQuery

For this operation we will use ASP.NET Custom validator

First in our markup we need to create a Custom Validator

<asp:CustomValidator ID="CustomPasswordRangeValidator"
ClientValidationFunction="ClientValidate" ControlToValidate="Password" runat="server"></asp:CustomValidator>

Now we will define a method in javascript this function will contain all the validation

function ValidateUserName(source, clientside_arguments) {
            //Test whether the length of the value is more than 6 characters
            if (clientside_arguments.Value.length >= 4 && clientside_arguments.Value.length <= 10) {
                clientside_arguments.IsValid = true;
            }
            else {
                clientside_arguments.IsValid = false
                source.innerHTML = "UserName must be between 5 to 10 characters";
            };
 
this function check if the string length is greater than 4 and less than 10 than it will be allowed.
 
else we will set a custom error message
 
I hope it was informative for you and I would like to Thank you for reading 

Tuesday, March 18, 2014

Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.



This error comes up when the web application is using different version of framework than IIS

To fix this problem first check which framework your application is using, by right click on the project and click on properties

After than open up IIS and Double click on Application Pools

On the right panel double on your website and select the appropriate framwork version

That's it and now your website should work

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

Tuesday, March 11, 2014

How to change css from Code Behind

Normally css is changed though jQuery but in this tutorial I will show you how you can change a control css from code behind.

First we need to find the control

HtmlControl myControl1 = (HtmlControl)Page.Master.FindControl("Label1");
         
            myControl1.Attributes.Add("style", "display:none");


In the above example we are first finding an element Label1 which is inside our master page, after finding the control we are saving it in myControl1 who's type is HtmlControl

Now using Control1.attributes.Add()

We can add any css

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

Tuesday, March 4, 2014

Insert default text in TextBox ASP.NET

You can insert default text in TextBox to assist your users what value to insert in the Textbox


            onBlur="if (this.value=='') this.value = 'Default Value'" onfocus="if (this.value=='Default Value') this.value = ''

When the Textbox looses focus it's value will automatically changes to Default Value and when the focus is inside the control its Default value will change so that user can type

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

Monday, March 3, 2014

Make Email address unique in create User Wizard ASP.NET

in createuserwizard the userid is unique by default

But in some cases we want to make both user id and email address unique so that a single user don't create multiple account.

we have 2 options

First option is that we can either edit the aspnet membership database and make userId and email as composite key which is not easy

2nd option is to this membership rule in web.config of our project

I will be using option number 2 for this tutorial

add the following taf in your web.config replace the name of connectionStringName as per your requirement

    <membership defaultProvider="CustomizedMembershipProvider">
      <providers>
        <add name="CustomizedMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" requiresUniqueEmail="true" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="1"/>
      </providers>
    </membership>


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

Saturday, January 4, 2014

Get GridView Cell value using jQuery ASP.NET

In this tutorial I will show you how you can get the cell value of Grid View using jQuery

You will first need to populate your gridview using any datasource

than using the jquery below

$("#<%=gv1.ClientID %> tr").each(function () {
                    if (!this.rowIndex) return;
                    var row = $(this).find("td:first");
                    alert(row[0].innerText);
                });
gv1 is the name of our gridview

using the each loop we iterate on each row

td:first indicate that we are only getting value of first column

we can also use

td:last
td:even
td:odd
td:eq("index number")
td:gt("Include element that are past the given index")
td:lt("Include element that are before the given index")
td:not()

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