Archive

Archive for March, 2013

Cascading Dropdown In SharePoint 2010 using SPService

March 28, 2013 Leave a comment

Hi all,

try this example to create cascading Dropdown in SharePoint 2010 using SPService

Step 1 : Download the Jquery file jquery-1.7.2.min.js by Jquery.com. Download jquery.SPServices-0.7.1a.zip from the Jquery Library for SharePoint Codeplex site. Upload jquery-1.7.2.min.js and jquery.SPServices-0.7.1a.min.js (from the zip file) to a document library.

Step 2 : Create your relational List and in this case i will create Three Custom Lists

– Countries List (The Parent List)

countries

– Cities List (The Child List) which has has one field in addition to the Title field; the Country field. This is a lookup field from the Countries list.

cities

– Hotels List (The Grandchild List) which has a Title field and a City field. The City field is a lookup field from the Cities list.

hotels

– Vacation Plans list which will contains cascading Dropdown which has Three lookup fields from Countries , Cities , and Hotels list

vacations

Step 3 : Open SharePoint 2010 Designer and from “Lists and Libraries” in the left pane select Vacation Plans List and click on NewForm.aspx or EditForm.aspx and select Edit in Advanced Mode in the ribbon and add the following code below

<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

Insert this Lines of code :


<script language="javascript" type="text/javascript" src="/addressToDocumentLibrary/jquery-1.7.2.min.js"></script>
<script language="javascript" type="text/javascript" src="/addressToDocumentLibrary/jquery.SPServices-0.7.1a.min.js"></script>
<script language="javascript" type="text/javascript">
 $(document).ready(function() {
 $().SPServices.SPCascadeDropdowns({
 relationshipList: "Cities",
 relationshipListParentColumn: "Country",
 relationshipListChildColumn: "Title",
 relationshipListSortColumn: "Title",
 parentColumn: "Country",
 childColumn: "City",
 debug: true
 });
$().SPServices.SPCascadeDropdowns({
 relationshipList: "Hotels",
 relationshipListParentColumn: "City",
 relationshipListChildColumn: "Title",
 parentColumn: "City",
 childColumn: "Hotel",
 debug: true
 });
});
</script>

save the changes and open your list and select add new item in Vacation Plans List

vacation

for more information you can visit this link

 

Hope this helps

Good Luck

Categories: SharePoint 2010

Get Number of Days of a Month in SQL Server

March 25, 2013 Leave a comment

Hi all,

try this example to get number of days of a month using SQL Server

first i’m going to create function which will take date and will return number of days of that date


CREATE FUNCTION [dbo].[Fn_GetDaysInMonth]
( @pDate DATETIME )
RETURNS INT
AS
BEGIN

SET @pDate = CONVERT(VARCHAR(10), @pDate, 101)
 SET @pDate = @pDate - DAY(@pDate) + 1
 RETURN DATEDIFF(DD, @pDate, DATEADD(MM, 1, @pDate))
END

and to test this SQL Function

select [dbo].[Fn_GetDaysInMonth] (getdate()) 

Hope this helps

Good Luck.

Categories: SQL Server

Disable Past Days in ASP Calender Control

March 17, 2013 Leave a comment

Hi all,

try this example to Disable Past Days in ASP Calender Control


<%@ Page Language="C#" %>
<html>
<head id="Head1" runat="server">
 <script runat="server">
 protected void DisablePastDays(object sender, DayRenderEventArgs e)
 {
 if (e.Day.Date < DateTime.Now)
 {
 e.Cell.Enabled = false;
 e.Day.IsSelectable = false;
 e.Cell.BackColor = System.Drawing.Color.Gray;
 }
 }
 </script>
</head>
<body>
 <form id="form1" runat="server">
 <asp:Calendar runat="server" ID="calDate" OnDayRender="DisablePastDays" />
 </form>
</body>
</html>

Hope this helps

Good Luck

Categories: ASP.Net

Conditionally changing a GridView row background or CSS stylesheet

March 16, 2013 Leave a comment

Hi all ,

try this example to Conditionally changing a gridview row background or css stylesheet

In GridView RowDataBound Event add the following code for Rows that i want to change background according to condition.


protected void Grid_RowDataBound(object sender, GridViewRowEventArgs e)
{
 if (e.Row.RowType == DataControlRowType.DataRow)
 {
 DateTime? engineerEnd =(DateTime?)Grid.DataKeys[e.Row.RowIndex]["EngineerEnd"];
 bool completed =(bool)Grid.DataKeys[e.Row.RowIndex]["Competed"];

 if (engineerEnd != null && completed == true)
 {
 e.Row.CssClass = "GridViewAdditional";
 }
}

Hope this helps

Good Luck.

Categories: ASP.Net

Enable Anonymous Access in SharePoint 2010

March 11, 2013 Leave a comment

Hi all,

try this example 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.

SharePoint-Site-Settings

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

SharePoint-Site-Permissions

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

SharePoint-Anonymous-Access

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

SharePoint-Select-Anonymous-Access-To-WebSite

Hope this helps

Good Luck.

 

 

 

Categories: SharePoint 2010

Get Day Number in SQL Server

March 10, 2013 Leave a comment

Hi all,

try this example to Get Day Number in SQL Server


select datename(dw,getdate()) --Friday

select datepart(dw,getdate()) --6

SELECT DATENAME(DW,GETDATE()) + ' ' + DATENAME(MM,GETDATE()) + ' ' +DATENAME(YY, GETDATE())

Hope this helps

Good Luck

Categories: SQL Server