Pages

Thursday, 4 July 2013

How To Add Identity Property to Existing Column in Table in SQL Server

How To Add Identity Property to Existing Column in Table in SQL Server

Create Table As Below

CREATE TABLE UserDtls

(

UserId int PRIMARY KEY,

UserName varchar(120),

Qualification varchar(50)

)

Now, Insert Data As Below

INSERT INTO UserDtls(UserId,UserName,Qualification) VALUES(1,'sizar','Be')

INSERT INTO UserDtls(UserId,UserName,Qualification) VALUES(2,'sahil','Be')

INSERT INTO UserDtls(UserId,UserName,Qualification) VALUES(3,'salim','Be')

The Table Is As Follow 

How To Add Identity Property to Existing Column in Table in SQL Server
How To Add Identity Property to Existing Column in Table in SQL Server

We can create identity column with above method only whenever we don't have any data in table otherwise we need to use T-SQL query for that follow below steps

1. Create another table(temp1) with same structure as old table(UserDtls) table with identity column.

2. Now move the data from UserDtls table to temp1 table for that you need to ON Identity insert property to know more about it check this article insert values in identity column in SQL.

3. Once inserted drop original table UserDtls and rename temp1 to UserDtls. For above steps below is the code we need to run to create identity column for existing table

     ---- Create New Table with Identity Column ------
CREATE TABLE temp1
(
UserId INT PRIMARY KEY IDENTITY,
UserName VARCHAR(120),
Qualification VARCHAR(50)
)
----Insert Data into newly created table----------
SET IDENTITY_INSERT temp1 ON
IF EXISTS(SELECT TOP 1 * FROM UserDtls)
BEGIN
INSERT INTO temp1(UserId,UserName,Qualification)
SELECT UserId,UserName,Qualification FROM UserDtls
END
SET IDENTITY_INSERT temp1 OFF
--------Once Data moved to new table drop old table --------
DROP TABLE UserDtls
-------Finally rename new table name to old table name
EXEC sp_rename 'temp1','UserDtls'         


By using above method we can add identity property to existing column in table using using SQL Server.

How To Do Exception Handling in SQL Server Stored Procedure with TRY CATCH in Asp.Net C#

How To Do Exception Handling in SQL Server Stored Procedure with TRY CATCH in Asp.Net C#

To handle exceptions in SQL Server we can use TRY…… CATCH blocks. To use TRY…… CATCH blocks in stored procedure we need to write the query like as shown below

BEGIN TRY
---Write Your Code
END TRY
BEGIN CATCH
---Write Code to handle errors
END CATCH


In TRY block we will write our queries and in CATCH block we will write code to handle exceptions. In our SQL statements if any error occurs automatically it will move to CATCH block in that we can handle error messages. To handle error messages we have defined Error Functions in CATCH block those are

  ERROR_LINE() - This function will return error line number of SQL query which cause to raise error.

  ERROR_NUMBER() - This function will return error number which is unique and assigned to it.

  ERROR_SEVERITY() - This function will return severity of error which indicates how serious the error is. The values are between 1 and 25.

  ERROR_STATE() - This function will return state number of error message which cause to raise error.

  ERROR_PROCEDURE() - This function will return name of the procedure where an error occurred.

  ERROR_MESSAGE() - This function will return the complete text of the error message which cause to raise error.

 Check below sample query to handle errors in stored procedure

BEGIN TRY
SELECT 300/0
END TRY
BEGIN CATCH
SELECT ErrorNumber = ERROR_NUMBER(), ErrorSeverity = ERROR_SEVERITY(), ErrorState =ERROR_STATE(),
ErrorProcedure = ERROR_PROCEDURE(), ErrorLine = ERROR_LINE(), ErrorMessage = ERROR_MESSAGE()
END CATCH

Demo:


How To Do Exception Handling in SQL Server Stored Procedure with TRY CATCH in Asp.Net C#
How To Do Exception Handling in SQL Server Stored Procedure with TRY CATCH in Asp.Net C#

How To Remove Duplicate Values from Arraylist String Using JavaScript C# ASp.Net

How To Remove Duplicate Values from Arraylist String Using JavaScript C# ASp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Remove duplicates </title>
<script type="text/javascript">
    function RemoveList() {
        var sampleArr = new Array(1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4,5,5); //Sample array
        uniqueArr(sampleArr);
    }
    //Adds new uniqueArr values to temp array
    function uniqueArr(arr) {
        arr1 = new Array();
        for (i = 0; i < arr.length; i++) {
            if (!checkstatus(arr1, arr[i])) {
                arr1.length += 1;
                arr1[arr1.length - 1] = arr[i];
            }
        }
        alert(arr1);
    }
    // Check if it contains unique or duplicate record
    function checkstatus(arr, e) {
        for (j = 0; j < arr.length; j++) if (arr[j] == e) return true;
        return false;
    }
</script>
</head>
<body>
<div>
<input type="button" value="Remove Duplicates" onclick="RemoveList()" />
</div>
</body>
</html>

Live Demo:

For live demo click on below button it will return only unique values from this string (1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4,5,5) values
Remove duplicates

How To Remove Last Character from String in VB.NET C# Asp.Net

 How To Remove Last Character from String in VB.NET C#  Asp.Net

Method 1 in C#

protected void Page_Load(object sender, EventArgs e)
{
string istr = "1,2,3,4,5,6,7,8,9,10,";
string ostr = istr.Remove(istr.Length - 1, 1);
Response.Write(ostr);
}

Method 1 in VB.NET

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim istr As String = "1,2,3,4,5,6,7,8,9,10,"
Dim ostr As String = istr.Remove(istr.Length - 1, 1)
Response.Write(ostr)
End Sub

Method 2 in C#

protected void Page_Load(object sender, EventArgs e)
{
string istr = "1,2,3,4,5,6,7,8,9,10,";
string ostr = istr.Trim(",".ToCharArray());
Response.Write(ostr);
}

Method 2 in VB.NET

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim istr As String = "1,2,3,4,5,6,7,8,9,10,"
Dim ostr As String = istr.Trim(",".ToCharArray())
Response.Write(ostr)
End Sub

Wednesday, 3 July 2013

How To Split String Example in VB.NET Or Split String with Special Characters (comma, underscore etc) in C# Asp.Net

How To Split String Example in VB.NET Or Split String with Special Characters (comma, underscore etc) in C# Asp.Net


Program:

.Aspx File:

Split String with one character in C#


protected void Page_Load(object sender, EventArgs e)
{
string istr = "Welcome to  fantasyaspnet.blogspot.in.";
string []ostr = istr.Split("-".ToCharArray());
foreach (string s in ostr)
{
Response.Write(s+"<br/>");
}
}

Split String with one character in VB.NET


Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim istr As String = "welcome to fantasyaspnet.blogspot.in."
Dim ostr As String() = istr.Split(".".ToCharArray())
For Each s As String In ostr
Response.Write(s & "<br/>")
Next
End Sub

Output

Welcome to fantasyaspnet
blogspot
in.

Split String with multiple characters in C#


protected void Page_Load(object sender, EventArgs e)
{
string istr = "welcome, to, fantasyaspnet.blogspot.in.";
string []ostr = istr.Split(",-.".ToCharArray());
foreach (string s in ostr)
{
Response.Write(s+"<br/>");
}
}

Split String with multiple characters in VB.NET


Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim istr As String = "welcome, to,  fantasyaspnet.blogspot.in."
Dim ostr As String() = istr.Split(",-.".ToCharArray())
For Each s As String In ostr
Response.Write(s & "<br/>")
Next
End Sub

Output

welcome
 to
 fantasyaspnet.blogspot.in

How To Get Access Session Variable Value in Asp.net c# Using jQuery

How To Get Access Session Variable Value in Asp.net c# Using jQuery


Program:

.Aspx File:

<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function () {
        var name = '<%= Session["UserName"] %>'
        $('#lbltxt').text(name)
    });
</script>
</head>
<body>
<label id="lbltxt" />
</body>
</html>

How To Enable or Disable a Controls Like Button, Textbox, Checkbox Using JavaScript in C# Asp.Net

How To Enable or Disable a Controls Like Button, Textbox, Checkbox Using JavaScript in C# Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Enable or Disable a control</title>
<script language="javascript" type="text/javascript">
    //function to enable button if two textboxes contains text
    function SetButtonStatus() {
        var txt = document.getElementById('txtfirst');
        //Condition to check whether user enters text in two textboxes or not
        if (txt.value.length >= 1)
            document.getElementById('btnButton').disabled = false;
        else
            document.getElementById('btnButton').disabled = true;
    }
</script>
</head>
<body>
<div>
<b>Enter Text:</b><input type="text" id="txtfirst" onkeyup="SetButtonStatus(this,'btnButton')"/>
<input type="button" id="btnButton" value="Button" disabled="disabled" />
</div>
</body>
</html>

Live Demo:

Enable or Disable a control
Enter Text:

How To Make OnClick Select All the Text from Textarea or Textbox Controls Using JavaScript in C# Asp.Net

How To Make OnClick Select All the Text from Textarea or Textbox Controls Using JavaScript in C# Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>onclick select all textarea</title>
<script type="text/javascript">
    function SelectAll(id) {
        document.getElementById(id).focus();
        document.getElementById(id).select();
    }
</script>
</head>
<body>
<div>
Enter Text:<br/>
<input type="text" id="txtfld" onclick="SelectAll('txtfld');" style="width:200px" value = "This text you can select all" /><br />
Textarea:<br/>
<textarea rows="5" cols="23" id="txtarea" onclick="SelectAll('txtarea');" style="width:200px" >Hi, Click hear </textarea>
</div>
</body>
</html>

Live Demo:

onclick select all textarea
Enter Text:

Textarea:

How To Get Gridview Row Values When Checkbox Selected in C# and Vb in Asp.net

How To Get Gridview Row Values When Checkbox Selected in C# and Vb in Asp.net 


Program:

.Aspx File:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="first.aspx.cs" Inherits="first" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get Checkbox Selected Row Values from Gridview</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="gvDetails" DataKeyNames="UserId" AutoGenerateColumns="false" CellPadding="5" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="UserId" DataField="UserId" />
<asp:BoundField HeaderText="UserName" DataField="UserName" />
<asp:BoundField HeaderText="Education" DataField="Education" />
<asp:BoundField HeaderText="Location" DataField="Location" />
</Columns>
<HeaderStyle BackColor="#B52025" Font-Bold="true" ForeColor="White" />
</asp:GridView>
<asp:Button ID="btnProcess" Text="Get Selected Records" runat="server"
Font-Bold="true" onclick="btnProcess_Click" /><br />
<asp:Label ID="lblmsg" runat="server" />
</div>
</form>
</body>
</html>

C#

using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;

public partial class first : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGridviewData();
        }
    }
    protected void BindGridviewData()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("UserId", typeof(Int32));
        dt.Columns.Add("UserName", typeof(string));
        dt.Columns.Add("Education", typeof(string));
        dt.Columns.Add("Location", typeof(string));
        DataRow dtrow = dt.NewRow();  
        dtrow["UserId"] = 1;          
        dtrow["UserName"] = "Surani Sizar";
        dtrow["Education"] = "BE Computer";
        dtrow["Location"] = "Surat";
        dt.Rows.Add(dtrow);
        dtrow = dt.NewRow();            
        dtrow["UserId"] = 2;            
        dtrow["UserName"] = "Sahil";
        dtrow["Education"] = "BE EC";
        dtrow["Location"] = "Bharuch";
        dt.Rows.Add(dtrow);
        dtrow = dt.NewRow();            
        dtrow["UserId"] = 3;          
        dtrow["UserName"] = "Salim";
        dtrow["Education"] = "BE EC";
        dtrow["Location"] = "Mumbai";
        dt.Rows.Add(dtrow);
        gvDetails.DataSource = dt;
        gvDetails.DataBind();
    }
    protected void btnProcess_Click(object sender, EventArgs e)
    {
        string str = string.Empty;
        string strname = string.Empty;
        foreach (GridViewRow gvrow in gvDetails.Rows)
        {
            CheckBox chk = (CheckBox)gvrow.FindControl("chkSelect");
            if (chk != null & chk.Checked)
            {
                str += gvDetails.DataKeys[gvrow.RowIndex].Value.ToString() + ',';
                strname += gvrow.Cells[2].Text + ',';
            }
        }
        str = str.Trim(",".ToCharArray());
        strname = strname.Trim(",".ToCharArray());
        lblmsg.Text = "Selected UserIds: <b>" + str + "</b><br/>" + "Selected UserNames: <b>" + strname + "</b>";
    }
}

VB

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
Partial Class VBCode
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
BindGridviewData()
End If
End Sub
Protected Sub BindGridviewData()
Dim dt As New DataTable()
dt.Columns.Add("UserId", GetType(Int32))
dt.Columns.Add("UserName", GetType(String))
dt.Columns.Add("Education", GetType(String))
dt.Columns.Add("Location", GetType(String))
Dim dtrow As DataRow = dt.NewRow()
' Create New Row
dtrow("UserId") = 1
'Bind Data to Columns
dtrow("UserName") = "SureshDasari"
dtrow("Education") = "B.Tech"
dtrow("Location") = "Chennai"
dt.Rows.Add(dtrow)
dtrow = dt.NewRow()
' Create New Row
dtrow("UserId") = 2
'Bind Data to Columns
dtrow("UserName") = "MadhavSai"
dtrow("Education") = "MBA"
dtrow("Location") = "Nagpur"
dt.Rows.Add(dtrow)
dtrow = dt.NewRow()
' Create New Row
dtrow("UserId") = 3
'Bind Data to Columns
dtrow("UserName") = "MaheshDasari"
dtrow("Education") = "B.Tech"
dtrow("Location") = "Nuzividu"
dt.Rows.Add(dtrow)
gvDetails.DataSource = dt
gvDetails.DataBind()
End Sub
Protected Sub btnProcess_Click(sender As Object, e As EventArgs)
Dim str As String = String.Empty
Dim strname As String = String.Empty
For Each gvrow As GridViewRow In gvDetails.Rows
Dim chk As CheckBox = DirectCast(gvrow.FindControl("chkSelect"), CheckBox)
If chk IsNot Nothing And chk.Checked Then
str += gvDetails.DataKeys(gvrow.RowIndex).Value.ToString() + ","c
strname += gvrow.Cells(2).Text & ","c
End If
Next
str = str.Trim(",".ToCharArray())
strname = strname.Trim(",".ToCharArray())
lblmsg.Text = "Selected UserIds: <b>" & str & "</b><br/>" & "Selected UserNames: <b>" & strname & "</b>"
End Sub
End Class

Demo:


How To Get Gridview Row Values When Checkbox Selected in C# and Vb in Asp.net
How To Get Gridview Row Values When Checkbox Selected in C# and Vb in Asp.net 

How to Enable Anonymous Access in SharePoint 2010

How to Enable Anonymous Access in SharePoint 2010

To enable anonymous access to SharePoint Site we need to follow below steps
 1. Navigate to the site where you wish to enable anonymous access.

 2. Go to Site Actions - Site Settings.



How to Enable Anonymous Access in SharePoint 2010
How to Enable Anonymous Access in SharePoint 2010

3. Under Users and Permissions, click on Site Permissions.


How to Enable Anonymous Access in SharePoint 2010
How to Enable Anonymous Access in SharePoint 2010

4. Under the Edit tab, click on Anonymous Access.


How to Enable Anonymous Access in SharePoint 2010
How to Enable Anonymous Access in SharePoint 2010

5. Once open Anonymous Access Choose whether you want Anonymous users to have access to the entire Web site or to lists and libraries only, and then click on OK.


How to Enable Anonymous Access in SharePoint 2010
How to Enable Anonymous Access in SharePoint 2010

How To make jQuery Check Empty Value or Null Value OR Check if String Contains Null or Empty Value in C# Asp.Net

How To make jQuery Check Empty Value or Null Value OR Check if String Contains Null or Empty Value in C# Asp.Net


Program:

.Aspx File

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check if string empty or null</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function () {
        $('#btnCheck').click(function () {
            var txt = $('#txtName');
            if (txt.val() != null && txt.val() != '') {
                alert('you entered text ' + txt.val())
            }
            else {
                alert('Please enter text')
            }
        })
    });
</script>
</head>
<body>
<div>
Enter Text: <input type="text" id="txtName" />
<input type="button" id="btnCheck" value="Check" />
</div>
</body>
</html>

Live Demo:

Check if string empty or null
Enter Text:

How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010

How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010

To create new site in SharePoint 2010 we need to follow below steps 1. Open the SharePoint 2010 Central Administration


How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010
How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010

2. In the Application Management section, click the Manage web applications link. The page lists the referenced web applications on the server. For a basic installation, you have two: -The default site: SharePoint – 80 -The administration site: SharePoint Central Administration v4


How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010
How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010

3. Click the New icon in the top left corner and fill out the resulting form. This contains the authentication method and using an existing or new website in IIS. It also allows you to use anonymous access to the site as well as turning on SSL configuration options. Once the form is filled out, click OK.


How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010
How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010


How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010
How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010


How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010
How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010

4. The changes will then process and SharePoint will return the Application Created message if all is well. Click OK once more.


How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010
How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010

 5. The web application you just created is now listed under the SharePoint Central Application v4. Next you will create the Site Collection. Navigate to Central Administration > Application Management > Create Site Collections.


How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010
How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010
 6. Enter in the requested information and choose a template. After clicking OK, the site collection is now created. You can navigate to it via the URL specified.


How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010
How to Create a Site in SharePoint 2010 Or Create New Site in SharePoint 2010

How To Break or Exit For Each Loop in VB.NET Or Exit/Break For Loop in C#, VB.NET Asp.Net

How To Break or Exit For Each Loop in VB.NET Or Exit/Break For Loop in C#, VB.NET Asp.Net

C# Code: for loop example

for (int i = 0; i < 10; i++)
{
int j = 4;
if (j == i)
{
break;
}
}

for each loop example

string listingId = string.Empty;
foreach (GridViewRow gvRow in grdSearchResults.Rows)
{
if (gvRow.Cells[2].Text != "0")
{
listingId = gvRow.Cells[2].Text;
}
if (!string.IsNullOrEmpty(listingId))
{
break;
}
}

VB Code: for loop example

For i As Integer = 0 To 9
Dim j As Integer = 4
If j = i Then
Exit For
End If
Next

for each loop example

Dim listingId As String = String.Empty
For Each gvRow As GridViewRow In grdSearchResults.Rows
If gvRow.Cells(2).Text <> "0" Then
listingId = gvRow.Cells(2).Text
End If
If Not String.IsNullOrEmpty(listingId) Then
Exit For
End If
Next

How to Create a Survey in SharePoint 2010 Or SharePoint Survey Example

How to Create a Survey in SharePoint 2010 Or SharePoint Survey Example 


To create new survey in SharePoint site in 2010 we need to follow below steps 1. Login to your SharePoint site as the administrative account. 2. From the Site Actions, select View All Site Content.


How to Create a Survey in SharePoint 2010 Or SharePoint Survey Example
How to Create a Survey in SharePoint 2010 Or SharePoint Survey Example 

3. Once you open Site Content now click on Create


How to Create a Survey in SharePoint 2010 Or SharePoint Survey Example
How to Create a Survey in SharePoint 2010 Or SharePoint Survey Example 

4. Once click on create we will see lot of options in that select Survey from List section, once you select survey we can get textbox to create new survey in right side in that enter name and click create


How to Create a Survey in SharePoint 2010 Or SharePoint Survey Example
How to Create a Survey in SharePoint 2010 Or SharePoint Survey Example 

5. In the next screen it will ask you to fill your question and choices after that click finish button


How to Create a Survey in SharePoint 2010 Or SharePoint Survey Example
How to Create a Survey in SharePoint 2010 Or SharePoint Survey Example 

6. Once you click finish survey will create in next page click on your survey then it will show option like Respond to Survey click on it then it will display options for you select required option and click Finish then it will display result

How To Check Internet Connection using jQuery Example in C# Asp.Net

How To Check Internet Connection using jQuery Example in C# Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check Internet Connection</title>
<script type="text/javascript">
    function checkconnection() {
        var status = navigator.onLine;
        if (status) {
            alert("online");
        } else {
            alert("offline");
        }
    }
</script>
</head>
<body>
<div>
<input type="button" value="Check Connection" onclick="checkconnection()" />
</div>
</body>
</html>

Live Demo:

Check Internet Connection

How To Make jQuery Right Click Context Menu Example Or Custom jQuery Right Click Menu in Asp.Net

How To Make jQuery Right Click Context Menu Example Or Custom jQuery Right Click Menu in Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Custom Right Click using jQuery</title>
<script src="http://code.jquery.com/jquery-1.8.2.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        try {
            $(document).bind("contextmenu", function (e) {
                e.preventDefault();
                $("#custom-menu").css({ top: e.pageY + "px", left: e.pageX + "px" }).show(100);
            });
            $(document).mouseup(function (e) {
                var container = $("#custom-menu");
                if (container.has(e.target).length == 0) {
                    container.hide();
                }
            });
        }
        catch (err) {
            alert(err);
        }
    });
</script>
<style type="text/css">
#custom-menu
{
z-index: 1000;
position: absolute;
border: solid 2px black;
background-color: white;
padding: 5px 0;
display: none;
}
#custom-menu ol
{
padding: 0;
margin: 0;
list-style-type: none;
min-width: 130px;
width: auto;
max-width: 200px;
font-family:Verdana;
font-size:12px;
}
#custom-menu ol li
{
margin: 0;
display: block;
list-style: none;
padding: 5px 5px;
}
#custom-menu ol li:hover
{
background-color: #efefef;
}

#custom-menu ol li:active
{
color: White;
background-color: #000;
}

#custom-menu ol .list-devider
{
padding: 0px;
margin: 0px;
}

#custom-menu ol .list-devider hr
{
margin: 2px 0px;
}

#custom-menu ol li a
{
color: Black;
text-decoration: none;
display: block;
padding: 0px 5px;
}
#custom-menu ol li a:active
{
color: White;
}
</style>
</head>
<body>

<div id="custom-menu">
<ol>
<li><a href="http://www.blogger.com/blogger.g?blogID=6405515441738996713#">Reply</a> </li>
<li><a href="http://www.blogger.com/blogger.g?blogID=6405515441738996713#">Reply All</a> </li>
<li class="list-devider">
<hr />
</li>
<li><a href="http://www.blogger.com/blogger.g?blogID=6405515441738996713#">Mark as unread</a> </li>
<li><a href="http://www.blogger.com/blogger.g?blogID=6405515441738996713#">Delete</a> </li>
<li><a href="http://www.blogger.com/blogger.g?blogID=6405515441738996713#">Archive</a> </li>
<li class="list-devider">
<hr />
</li>
<li><a href="http://www.blogger.com/blogger.g?blogID=6405515441738996713#">Junk</a> </li>
<li><a href="http://www.blogger.com/blogger.g?blogID=6405515441738996713#">View</a> </li>
</ol>
</div>
</body>
</html>

For Live Demo Right Click On Page

Custom Right Click using jQuery

How To Use jQuery to Hide a DIV when Clicks Outside of it in JavaScript in Asp.Net C#

How To Use jQuery to Hide a DIV when Clicks Outside of it in JavaScript in Asp.Net C#


Program:

.Aspx File:


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Custom Right Click using jQuery</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        try {
            $(document).bind("contextmenu", function (e) {
                e.preventDefault();
                $("#custom-menu").css({ top: e.pageY + "px", left: e.pageX + "px" }).show(100);
            });
            $(document).mouseup(function (e) {
                var container = $("#custom-menu");
                if (container.has(e.target).length == 0) {
                    container.hide();
                }
            });
        }
        catch (err) {
            alert(err);
        }
    });
</script>
<style type="text/css">
#custom-menu
{
z-index: 1000;
position: absolute;
border: solid 2px black;
background-color: white;
padding: 5px 0;
display: none;
}
#custom-menu ol
{
padding: 0;
margin: 0;
list-style-type: none;
min-width: 130px;
width: auto;
max-width: 200px;
font-family:Verdana;
font-size:12px;
}
#custom-menu ol li
{
margin: 0;
display: block;
list-style: none;
padding: 5px 5px;
}
#custom-menu ol li:hover
{
background-color: #efefef;
}

#custom-menu ol li:active
{
color: White;
background-color: #000;
}

#custom-menu ol .list-devider
{
padding: 0px;
margin: 0px;
}

#custom-menu ol .list-devider hr
{
margin: 2px 0px;
}

#custom-menu ol li a
{
color: Black;
text-decoration: none;
display: block;
padding: 0px 5px;
}
#custom-menu ol li a:active
{
color: White;
}
</style>
</head>
<body>

<div id="custom-menu">
<ol>
<li><a href="#">Reply</a> </li>
<li><a href="#">Reply All</a> </li>
<li class="list-devider">
<hr />
</li>
<li><a href="#">Mark as unread</a> </li>
<li><a href="#">Delete</a> </li>
<li><a href="#">Archive</a> </li>
<li class="list-devider">
<hr />
</li>
<li><a href="#">Junk</a> </li>
<li><a href="#">View</a> </li>
</ol>
</div>
</body>
</html>

For Live Demo Right Click On Page

Custom Right Click using jQuery

How to Change Site Theme SharePoint 2010

How to Change Site Theme SharePoint 2010

1. Go to Site Actions -à Site Settings like as shown below figure


How to Change Site Theme SharePoint 2010
How to Change Site Theme SharePoint 2010

2. Once you open Site Settings in that go to Look and Feel -à Select site theme like as shown below


How to Change Site Theme SharePoint 2010
How to Change Site Theme SharePoint 2010

3. Once you open Site theme it will give option to select required theme as shown below


How to Change Site Theme SharePoint 2010
How to Change Site Theme SharePoint 2010

4. Once you select theme click Preview button then our site will be like as shown below


How to Change Site Theme SharePoint 2010
How to Change Site Theme SharePoint 2010

How to Delete a SharePoint Site from SharePoint Site Collection SharePoint 2010

How to Delete a SharePoint Site from SharePoint Site Collection SharePoint 2010

1. First select your site from site collections like as shown below


How to Delete a SharePoint Site from SharePoint Site Collection SharePoint 2010
How to Delete a SharePoint Site from SharePoint Site Collection SharePoint 2010

2. Once you open your site Go to Site Actions -à Site Settings like as shown below figure


How to Delete a SharePoint Site from SharePoint Site Collection SharePoint 2010
How to Delete a SharePoint Site from SharePoint Site Collection SharePoint 2010

3. Once you open Site Settings in that go to Site Actions -à Select Delete this site like as shown below


How to Delete a SharePoint Site from SharePoint Site Collection SharePoint 2010
How to Delete a SharePoint Site from SharePoint Site Collection SharePoint 2010

4. Once you open Delete this site option you can click on delete button and delete the site


How to Delete a SharePoint Site from SharePoint Site Collection SharePoint 2010
How to Delete a SharePoint Site from SharePoint Site Collection SharePoint 2010

5. Once site deleted from SharePoint site collection then we will get message like as shown below


How to Delete a SharePoint Site from SharePoint Site Collection SharePoint 2010
How to Delete a SharePoint Site from SharePoint Site Collection SharePoint 2010

How TO Open Or Show jQuery Modal POPUP Window on Page Load with Example in C# Asp,Net

How TO Open Or Show jQuery Modal POPUP Window on Page Load with Example in C# Asp,Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Show Popup on Page Load</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<style type="text/css">
#overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000;
filter:alpha(opacity=70);
-moz-opacity:0.7;
-khtml-opacity: 0.7;
opacity: 0.7;
z-index: 100;
display: none;
}
.cnt223 a{
text-decoration: none;
}
.popup{
width: 100%;
margin: 0 auto;
display: none;
position: fixed;
z-index: 101;
}
.cnt223{
min-width: 600px;
width: 600px;
min-height: 150px;
margin: 100px auto;
background: #f3f3f3;
position: relative;
z-index: 103;
padding: 10px;
border-radius: 5px;
box-shadow: 0 2px 5px #000;
}
.cnt223 p{
clear: both;
color: #555555;
text-align: justify;
}
.cnt223 p a{
color: #d91900;
font-weight: bold;
}
.cnt223 .x{
float: right;
height: 35px;
left: 22px;
position: relative;
top: -25px;
width: 34px;
}
.cnt223 .x:hover{
cursor: pointer;
}
</style>
<script type='text/javascript'>
    $(function () {
        var overlay = $('<div id="overlay"></div>');
        overlay.show();
        overlay.appendTo(document.body);
        $('.popup').show();
        $('.close').click(function () {
            $('.popup').hide();
            overlay.appendTo(document.body).remove();
            return false;
        });

        $('.x').click(function () {
            $('.popup').hide();
            overlay.appendTo(document.body).remove();
            return false;
        });
    });
</script>
</head>
<body>
<div class='popup'>
<div class='cnt223'>
<img src='http://www.developertips.net/demos/popup-dialog/img/x.png' alt='quit' class='x' id='x' />
<p>
Welcome to fantasyaspnet.blogspot.in.
<br/>
<br/>
<a href='' class='close'>Close</a>
</p>
</div>
</div>
</body>
</html>

Demo:


How TO Open Or Show jQuery Modal POPUP Window on Page Load with Example in C# Asp,Net
How TO Open Or Show jQuery Modal POPUP Window on Page Load with Example in C# Asp,Net

How To Get Current Page URL & Title Using jQuery Or JavaScript Get Current Page URL & Title in C# ASp.Net

How To Get Current Page URL & Title Using jQuery Or JavaScript Get Current Page URL & Title in C# ASp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get Curent Page Url</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function () {
        var url = $(location).attr('href');
        var title = $(this).attr('title');
        $('#spn_title').html('<strong>' + title + '</strong>');
        $('#spn_url').html('<strong>' + url + '</strong>');
    });
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>Current page URL: <span id="spn_url"></span>.</p>
<p>Current page title: <span id="spn_title"></span>.</p>
</div>
</form>
</body>
</html>

Live Demo:

Get Curent Page Url
Current page URL: .
Current page title: .

How To Get URL Parameters using jQuery Or Get Parameter Values From URL using jQuery in c# Asp.Net

How To Get URL Parameters using jQuery Or Get Parameter Values From URL using jQuery in c# Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get Current Page Url Parameter values</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function () {
        var name = GetParameterValues('username');
        var id = GetParameterValues('userid');
        $('#spn_UserName').html('<strong>' + name + '</strong>');
        $('#spn_UserId').html('<strong>' + id + '</strong>');
    });
    function GetParameterValues(param) {
        var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
        for (var i = 0; i < url.length; i++) {
            var urlparam = url[i].split('=');
            if (urlparam[0] == param) {
                return urlparam[1];
            }
        }
    }
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>UserName: <span id="spn_UserName"></span></p>
<p>UserId: <span id="spn_UserId"></span></p>
</div>
</form>
</body>
</html>

 Demo:

How To Get URL Parameters using jQuery Or Get Parameter Values From URL using jQuery in c# Asp.Net
How To Get URL Parameters using jQuery Or Get Parameter Values From URL using jQuery in c# Asp.Net

How To Get QueryString Value Or Get QueryString Parameter Values using jQuery in c# Asp.Net

How To  Get QueryString Value Or Get QueryString Parameter Values using jQuery in c# Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get Current Page Url Parameter values</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function () {
        var name = GetParameterValues('username');
        var id = GetParameterValues('userid');
        $('#spn_UserName').html('<strong>' + name + '</strong>');
        $('#spn_UserId').html('<strong>' + id + '</strong>');
    });
    function GetParameterValues(param) {
        var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
        for (var i = 0; i < url.length; i++) {
            var urlparam = url[i].split('=');
            if (urlparam[0] == param) {
                return urlparam[1];
            }
        }
    }
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>UserName: <span id="spn_UserName"></span></p>
<p>UserId: <span id="spn_UserId"></span></p>
</div>
</form>
</body>
</html>

Demo:

How To  Get QueryString Value Or Get QueryString Parameter Values using jQuery in c# Asp.Net
How To  Get QueryString Value Or Get QueryString Parameter Values using jQuery in c# Asp.Net

Tuesday, 2 July 2013

How To Add Blinking text using jQuery Or Blinking Effect to Text in jQuery in c# Asp.Net

How To Add Blinking text using jQuery Or Blinking Effect to Text in jQuery in c# Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>blinking effect to text</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function () {
        blinkeffect('#txtblnk');
    })
    function blinkeffect(selector) {
        $(selector).fadeOut('slow', function () {
            $(this).fadeIn('slow', function () {
                blinkeffect(this);
            });
        });
    }
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="txtblnk"> <p><strong><font color="red">Welcome to fantasyaspnet.blogspot.in</font></strong></p> </div>
</form>
</body>
</html>

Live Demo:

blinking effect to text
Welcome to fantasyaspnet.blogspot.in

How To Generate Random Colors in JavaScript Or Random Color Generator in JavaScript in c# Asp.Net

How To Generate Random Colors in JavaScript Or Random Color Generator in JavaScript in c# Asp.Net


Program:

.Aspx File:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Random Colors</title>
    <script type="text/javascript">

        setInterval(rgbcolors, 1000);
        function rgbcolors() {

            var col = "rgb(" + Math.floor(Math.random() * 255) + "," + Math.floor(Math.random() * 255) + "," + Math.floor(Math.random() * 255) + ")";
            document.getElementById("divstyle").style.color = col;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="divstyle" style="font: bold 24px verdana">
        Sizar Surani</div>
    </form>
</body>

Live Demo:

Random Colors
Sizar Surani