Wednesday, May 9, 2012

Page Layout with default webpart

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="LayoutWithWebPart" List="116"  Url="_catalogs/masterpage">
    <File Path="LayoutWithWebPart\LayoutWithWebPart.aspx" Url="LayoutWithWebPart.aspx" IgnoreIfAlreadyExists="TRUE" Type="GhostableInLibrary">
      <AllUsersWebPart WebPartZoneID="RightColumn" WebPartOrder="1">
     

        <![CDATA[
    <webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <type name="VCSB.INTRANET.ViewArticlesInnerWebpart.ViewArticlesInnerWebpart, VCSB.INTRANET, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5c6b1aa174bc8565" />
      <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="Title" type="string">ViewArticlesInnerWebpart</property>
        <property name="Description" type="string">My Visual WebPart</property>
      </properties>
    </data>
  </webPart>
</webParts>
      ]]>

      </AllUsersWebPart>
      <AllUsersWebPart WebPartZoneID="Part2" WebPartOrder="2">

        <![CDATA[
    <webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <type name="VCSB.INTRANET.CongratulationInnerPageSingleWebPart.CongratulationInnerPageSingleWebPart, VCSB.INTRANET, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5c6b1aa174bc8565" />
      <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="Title" type="string">CongratulationInnerPageSingleWebPart</property>
        <property name="Description" type="string">My Visual WebPart</property>
      </properties>
    </data>
  </webPart>
</webParts>
      ]]>
      </AllUsersWebPart>

    </File>
  </Module>
</Elements>

Friday, May 4, 2012

Custom Breadcrumb in sharepoint

To Create breadcrumb in sharepoint page or in page layout
paste this code in desired place

<asp:SiteMapPath SiteMapProvider="SPContentMapProvider" id="ContentMap"  SkipLinkText="" RenderCurrentNodeAsLink="true"  NodeStyle-CssClass="ms-sitemapdirectional" runat="server"/>
it will result as,

Monday, April 30, 2012


Step1: Create a Empty sharepoint project [MyCustom Layout]


Step2:create a module in that project by choosing add new item




Step3:In that module Delete sample.txt file and add a aspx page by choosing add new item -General -TextFile and Give name as MyCustomLayout.aspx




Step4: Replace the element file code with the following....

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="masterpage" Url="_catalogs/masterpage">

    <File Path="MyCustomLayout\MyCustomLayout.aspx" Url="MyCustomLayout.aspx" >
   
     
    </File>
</Module>
</Elements>

Step5:open that aspx page and put your desired layout in that  aspx page......


Note:Here am pasting a template a webpart page layout.

It will result as .........(a Page content will be appear above that webpart zones)



<%@ Page language="C#"   Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ContentPlaceholderID="PlaceHolderAdditionalPageHead" runat="server">
<SharePointWebControls:UIVersionedContent ID="UIVersionedContent1" UIVersion="3" runat="server">
<ContentTemplate>
<style type="text/css">
Div.ms-titleareaframe {
height: 100%;
}
.ms-pagetitleareaframe table {
background: none;
}
</style>
</ContentTemplate>
</SharePointWebControls:UIVersionedContent>
<SharePointWebControls:UIVersionedContent ID="UIVersionedContent2" UIVersion="4" runat="server">
<ContentTemplate>
<SharePointWebControls:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/~language/Core Styles/page-layouts-21.css %>" runat="server"/>
<PublishingWebControls:EditModePanel ID="EditModePanel1" runat="server">
<!-- Styles for edit mode only-->
<SharePointWebControls:CssRegistration ID="CssRegistration1" name="<% $SPUrl:~sitecollection/Style Library/~language/Core Styles/edit-mode-21.css %>"
After="<% $SPUrl:~sitecollection/Style Library/~language/Core Styles/page-layouts-21.css %>" runat="server"/>
</PublishingWebControls:EditModePanel>
</ContentTemplate>
</SharePointWebControls:UIVersionedContent>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
<SharePointWebControls:UIVersionedContent ID="UIVersionedContent3" UIVersion="3" runat="server">
<ContentTemplate>
<SharePointWebControls:ListProperty Property="Title" runat="server"/> - <SharePointWebControls:ListItemProperty Property="BaseName" MaxLength=40 runat="server"/>
</ContentTemplate>
</SharePointWebControls:UIVersionedContent>
<SharePointWebControls:UIVersionedContent ID="UIVersionedContent4" UIVersion="4" runat="server">
<ContentTemplate>
<SharePointWebControls:ListProperty Property="Title" runat="server"/> - <SharePointWebControls:FieldValue FieldName="Title" runat="server"/>
</ContentTemplate>
</SharePointWebControls:UIVersionedContent>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
<SharePointWebControls:VersionedPlaceHolder ID="VersionedPlaceHolder1" UIVersion="3" runat="server">
<ContentTemplate>
<WebPartPages:WebPartZone runat="server" Title="loc:TitleBar" ID="TitleBar" AllowLayoutChange="false" AllowPersonalization="false"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
</ContentTemplate>
</SharePointWebControls:VersionedPlaceHolder>
<SharePointWebControls:UIVersionedContent ID="UIVersionedContent5" UIVersion="4" runat="server">
<ContentTemplate>
<SharePointWebControls:FieldValue FieldName="Title" runat="server" />
</ContentTemplate>
</SharePointWebControls:UIVersionedContent>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderTitleBreadcrumb" runat="server">
<SharePointWebControls:VersionedPlaceHolder ID="VersionedPlaceHolder2" UIVersion="3" runat="server"> <ContentTemplate> <asp:SiteMapPath ID="siteMapPath" runat="server" SiteMapProvider="CurrentNavigation" RenderCurrentNodeAsLink="false" SkipLinkText="" CurrentNodeStyle-CssClass="current" NodeStyle-CssClass="ms-sitemapdirectional"/> </ContentTemplate> </SharePointWebControls:VersionedPlaceHolder>
<SharePointWebControls:UIVersionedContent ID="UIVersionedContent6" UIVersion="4" runat="server"> <ContentTemplate> <SharePointWebControls:ListSiteMapPath runat="server" SiteMapProviders="CurrentNavigation" RenderCurrentNodeAsLink="false" PathSeparator="" CssClass="s4-breadcrumb" NodeStyle-CssClass="s4-breadcrumbNode" CurrentNodeStyle-CssClass="s4-breadcrumbCurrentNode" RootNodeStyle-CssClass="s4-breadcrumbRootNode" NodeImageOffsetX=0 NodeImageOffsetY=353 NodeImageWidth=16 NodeImageHeight=16 NodeImageUrl="/_layouts/images/fgimg.png" HideInteriorRootNodes="true" SkipLinkText="" /> </ContentTemplate> </SharePointWebControls:UIVersionedContent> </asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageDescription" runat="server">
<SharePointWebControls:ProjectProperty ID="ProjectProperty1" Property="Description" runat="server"/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderBodyRightMargin" runat="server">
<div height=100% class="ms-pagemargin"><IMG SRC="/_layouts/images/blank.gif" width=10 height=1 alt=""></div>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<SharePointWebControls:UIVersionedContent ID="UIVersionedContent7" UIVersion="4" runat="server">
<ContentTemplate>
<div class="welcome blank-wp">
<PublishingWebControls:EditModePanel ID="EditModePanel2" runat="server" CssClass="edit-mode-panel">
<SharePointWebControls:TextField ID="TextField1" runat="server" FieldName="Title"/>
</PublishingWebControls:EditModePanel>
<div class="welcome-content">
<PublishingWebControls:RichHtmlField ID="RichHtmlField1" FieldName="PublishingPageContent" HasInitialFocus="True" MinimumEditHeight="400px" runat="server"/>
</div>
</ContentTemplate>
</SharePointWebControls:UIVersionedContent>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<SharePointWebControls:UIVersionedContent ID="UIVersionedContent8" UIVersion="3" runat="server">
<ContentTemplate>
<tbody>
<tr>
<td valign="top" style="padding:0" colspan="3" width="100%">
<PublishingWebControls:RichHtmlField id="PageContent" FieldName="PublishingPageContent" runat="server"/>
</td>
</tr>
</ContentTemplate>
</SharePointWebControls:UIVersionedContent>
<tr>
<td valign="top" style="padding:0">
<table cellpadding="4" cellspacing="0" border="0" width="100%" height="100%">
<tr>
<td id="_invisibleIfEmpty" name="_invisibleIfEmpty" colspan="3" valign="top">
<WebPartPages:WebPartZone runat="server" Title="<%$Resources:cms,WebPartZoneTitle_Header%>" ID="Header"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone> </td>
</tr>
<tr>
<td width="100%" colspan="3" valign="top" style="padding:0">

<table cellpadding="4" cellspacing="0" width="100%" height="100%">
                            <tr>
                            <td width="100%">
                            <img src="/_layouts/images/MyCustomPageLayout/HeaderVolusia.jpg" />
                            </td>
                            </tr>
<tr>
<td id="_invisibleIfEmpty" name="_invisibleIfEmpty" valign="top">
<WebPartPages:WebPartZone runat="server" Title="<%$Resources:cms,WebPartZoneTitle_TopLeft%>" ID="TopLeftRow"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
                                     </td>
<td id="_invisibleIfEmpty" name="_invisibleIfEmpty" valign="top">
<WebPartPages:WebPartZone runat="server" Title="<%$Resources:cms,WebPartZoneTitle_TopRight%>" ID="TopRightRow"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
                                                                     </td>
</tr>
</table>
</td>
</tr> <tr>
<td id="_invisibleIfEmpty" name="_invisibleIfEmpty" valign="top" height="100%">
<WebPartPages:WebPartZone runat="server" Title="<%$Resources:cms,WebPartZoneTitle_CenterLeft%>" ID="CenterLeftColumn"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone> </td>
<td id="_invisibleIfEmpty" name="_invisibleIfEmpty" valign="top" height="100%">
<WebPartPages:WebPartZone runat="server" Title="<%$Resources:cms,WebPartZoneTitle_Center%>" ID="CenterColumn"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone> </td>
<td id="_invisibleIfEmpty" name="_invisibleIfEmpty" valign="top" height="100%">
<WebPartPages:WebPartZone runat="server" Title="<%$Resources:cms,WebPartZoneTitle_CenterRight%>" ID="CenterRightColumn"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone> </td>
</tr>
<tr>
<td id="_invisibleIfEmpty" name="_invisibleIfEmpty" colspan="3" valign="top">
<WebPartPages:WebPartZone runat="server" Title="<%$Resources:cms,WebPartZoneTitle_Footer%>" ID="Footer"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone> </td>
</tr>
</table>
</td>
<td id="_invisibleIfEmpty" name="_invisibleIfEmpty" valign="top" height="100%">
<WebPartPages:WebPartZone runat="server" Title="<%$Resources:cms,WebPartZoneTitle_Right%>" ID="RightColumn" Orientation="Vertical"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone> </td>
            <td>
            New Page Layout
            </td>

</tr>
<script language="javascript">    if (typeof (MSOLayout_MakeInvisibleIfEmpty) == "function") { MSOLayout_MakeInvisibleIfEmpty(); }</script>
</table>
<SharePointWebControls:UIVersionedContent ID="UIVersionedContent9" UIVersion="4" runat="server">
<ContentTemplate>
</div>
</ContentTemplate>
</SharePointWebControls:UIVersionedContent>
</asp:Content>




Step6: Deploy that project to your site(It will be created , we can find that with masterpages and page layouts )




Step7:Approve that page layout








Step8: Go to Page Layouts and site templates in site settings,Add Your Page layout to Right Column box  and Click OK .



Step9: Create a publishing Page by:

View all site content-Create-Page-Publishing Page-Select your Custom template there.





Friday, April 27, 2012

LogOut Customization

LogOut Customization:

When Creating master page ,
Need to customize logout -in that masterpage coding
"Welcom.ascx" Usercontrol will be registered,like

  <%@ Register TagPrefix="wssuc" TagName="Welcome" Src="~/_controltemplates/Welcome.ascx" %> 
that Welcome.ascx usercontrol is having the following code

---------------------------------------------------------------------------------------------------------


<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" Inherits="Microsoft.SharePoint.WebControls.Welcome,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c"   AutoEventWireup="false" compilationMode="Always" %>
  <SharePoint:PersonalActions accesskey="<%$Resources:wss,personalactions_menu_ak%>" ToolTip="<%$Resources:wss,open_menu%>" runat="server" id="ExplicitLogout" Visible="false">
<CustomTemplate>
<SharePoint:FeatureMenuTemplate runat="server"
FeatureScope="Site"
Location="Microsoft.SharePoint.StandardMenu"
GroupId="PersonalActions"
id="ID_PersonalActionMenu"
UseShortId="true"
>
<SharePoint:MenuItemTemplate runat="server" id="ID_PersonalInformation"
Text="<%$Resources:wss,personalactions_personalinformation%>"
Description="<%$Resources:wss,personalactions_personalinformationdescription%>"
MenuGroupId="100"
Sequence="100"
ImageUrl="/_layouts/images/menuprofile.gif"
UseShortId="true"
/>
<SharePoint:MenuItemTemplate runat="server" id="ID_LoginAsDifferentUser"
Text="<%$Resources:wss,personalactions_loginasdifferentuser%>"
Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>"
MenuGroupId="200"
Sequence="100"
UseShortId="true"
/>
<SharePoint:MenuItemTemplate runat="server" id="ID_RequestAccess"
Text="<%$Resources:wss,personalactions_requestaccess%>"
Description="<%$Resources:wss,personalactions_requestaccessdescription%>"
MenuGroupId="200"
UseShortId="true"
Sequence="200"
/>
<SharePoint:MenuItemTemplate runat="server" id="ID_Logout"
Text="<%$Resources:wss,personalactions_logout%>"
Description="<%$Resources:wss,personalactions_logoutdescription%>"
MenuGroupId="200"
Sequence="300"
UseShortId="true"
/>
<SharePoint:MenuItemTemplate runat="server" id="ID_PersonalizePage"
Text="<%$Resources:wss,personalactions_personalizepage%>"
Description="<%$Resources:wss,personalactions_personalizepagedescription%>"
ImageUrl="/_layouts/images/menupersonalize.gif"
ClientOnClickScript="javascript:ChangeLayoutMode(true);"
PermissionsString="AddDelPrivateWebParts,UpdatePersonalWebParts"
PermissionMode="Any"
MenuGroupId="300"
Sequence="100"
UseShortId="true"
/>
<SharePoint:MenuItemTemplate runat="server" id="ID_SwitchView"
MenuGroupId="300"
Sequence="200"
UseShortId="true"
/>
<SharePoint:MenuItemTemplate runat="server" id="MSOMenu_RestoreDefaults"
Text="<%$Resources:wss,personalactions_restorepagedefaults%>"
Description="<%$Resources:wss,personalactions_restorepagedefaultsdescription%>"
ClientOnClickNavigateUrl="javascript:SP.SOD.execute('browserScript', 'MSOWebPartPage_RestorePageDefault')"
MenuGroupId="300"
Sequence="300"
UseShortId="true"
/>
</SharePoint:FeatureMenuTemplate>
</CustomTemplate>
</SharePoint:PersonalActions>
<SharePoint:ApplicationPageLink runat="server" id="ExplicitLogin"
ApplicationPageFileName="Authenticate.aspx" AppendCurrentPageUrl=true
Text="<%$Resources:wss,login_pagetitle%>" style="display:none" Visible="false" />


---------------------------------------------------------------------------------------------------


We can add a new customized usercontrol that is called "CustomWelcome.ascx"
by customize this page using welcome.ascx  we can use different logout options.

call this CustomWelcome.ascx in master page instead of welcome.ascx
that is ,


 <%@ Register TagPrefix="wssuc" TagName="Welcome" Src="~/_controltemplates/CustomWelcome.ascx" %>


by using following code u can get personal info of that user who was logged in


 <SharePoint:MenuItemTemplate runat="server" id="ID_PersonalInformation"
Text="<%$Resources:wss,personalactions_personalinformation%>"
Description="<%$Resources:wss,personalactions_personalinformationdescription%>"
MenuGroupId="100"
Sequence="100"
ImageUrl="/_layouts/images/menuprofile.gif"
UseShortId="true"
/>



Friday, March 30, 2012

cascading drop-downs

Ever since Microsoft came out with SharePoint it has been difficult to implement cascading drop-down lists (more on what they are, in a minute.) If you ask me, this is nuts! Cascading drop-downs are the bread and butter of easy-to-use forms.

What are cascading drop-downs?

The canonical example of a set of cascading drop-downs is a form that requires the user to add a state and a city. The screen shot below illustrates the point. When the user selects the state of New York, she sees the following cities in the City drop-down: New York, Buffalo, Rochester, Yonkers, Syracuse. However, when she picks Wisconsin as the state, she sees Milwaukee, Madison, Green Bay as the possible cities to choose from. The term "cascading" implies that the contents of the City drop-down depends upon what has been selected in the State drop-down.
2011-03-23-BrowserBasedInfopath-01.png

A Little History

Historically, one had to know quite a bit to implement cascading drop-downs. To my knowledge, there were two ways to create cascading drop-downs:
  1. The traditional "development" approach, which involves back end development and deployment .
  2. The java script approach (No back-end deployment necessary): One keeps the State/City data in a SharePoint list, and use javascript to make calls into SharePoint's web services. The java-script that you must write is fairly intricate. If you want to make your life significantly easier, you can use Marc Anderson's library, SPServices. This approach still involves writing a little bit of javascript, leveraging jQuery, and knowing how to use Marc's SP Services library. It is not rocket science, but it is beyond most business users.
Before describing the no code InfoPath solution, let me point out the advantages and disadvantages of the two above mentioned solutions:
For the traditional development approach there are two big disadvantages:
  1. You must have a .NET developer who understands SharePoint development to create the cascading lists.
  2. You must deploy the solution through the back end. This means that you need access to Central Administration (CA). IT groups can do this, but typical business users cannot.
For the java script approach, there are two advantages:
  1. You can implement this on WSS (the free version of SharePoint 2007) as well as SharePoint Foundation (the free version of SharePoint 2010.)
  2. The other great thing about this approach is it does not require access to the back end (Central Administration). Thus business users who do not have access to the back end can implement this. This is also a good solution if you are renting a SharePoint environment and do not have access to CA, which is quite common.

Cascading Drop-downs using InfoPath 2010

Before you read on, I must tell you that this approach only works if you have the Enterprise version of SharePoint 2010 or the forms server. You will also need to have InfoPath 2010 Designer installed on your client machine. Now that 75% of my readers have dropped off... If you do have the right version installed, then this no code approach is easy to follow.
One great thing about InfoPath 2010 is that you no longer have to create pure InfoPath forms. You can customize the Out-of-the-box native SharePoint forms that are automatically generated when you create any sort of list or document library. So that means we can create two or more cascading drop-downs in a standard New / Edit form for a list or document library.
Let's get started:
Step 1: Create the list of states and cities by creating a custom list. Let's call it States and in addition to the default column called, "Title", let's add City as a new text column. Then let's populate the list with some States and Cities. Below is a screen shot that illustrates the new list. If you are following along, for your convenience I have included an Excel file with some States and Cities: Download States:
2011-03-23-BrowserBasedInfopath-02.png
Step 2: So now that you have created the States list, let's create a new list in which we will give the user a set of cascading drop-down lists. Go ahead and create a custom list and call it List of Accounts, or anything you like. Once you have created the list, you will see that you can launch the InfoPath designer by clicking on the "Customize Form" icon depicted in the screenshot below (marked with a 2 in hand written red ink)
2011-03-23-BrowserBasedInfopath-03.png
Step 3: Once InfoPath designer launches, add a Receive connection to the States SharePoint list.
  1. Click on Manage Data Connections...
  2. Click on Add..
  3. Click on Receive data then on Next
  4. Click on SharePoint Library or list then on Next
  5. Provide the URL of States List then on Next
  6. Pick the States list then on Next
  7. Check off Title and City the click on Next
  8. Then keep going with Next, until you get to Finish.
Click on Manage Data Connections...
2011-03-23-BrowserBasedInfopath-04.png
Click on Add..
2011-03-23-BrowserBasedInfopath-05.png
Click on Receive data
2011-03-23-BrowserBasedInfopath-06.png
Click on SharePoint Library or list
2011-03-23-BrowserBasedInfopath-07.png
Provide the URL of States List
2011-03-23-BrowserBasedInfopath-08.png
Pick the States list
2011-03-23-BrowserBasedInfopath-09.png
Check off Title and City
2011-03-23-BrowserBasedInfopath-10.png
Then keep going with Next, until you get to Finish
2011-03-23-BrowserBasedInfopath-11.png
Now that you have the connection we will create two drop-down lists that leverage this connection.
Step 4: Create two drop-down lists boxes and call the first one State and the other one City. By default InfoPath will call them field 1 and field 2. I renamed them to State and City.
2011-03-23-BrowserBasedInfopath-12.png
NOTE: When you add the drop down list boxes, InfoPath will ask you whether you want to add the choices manually or whether you want to look them up in a list. Pick the Manual Choices. We will set these lists up in a moment.
Step 5: In step 6 we will ensure that the City drop-down lists will work in concert with the State drop-down. In this step we will make sure that the State drop-down gets the list of States.
Right click on the States drop-down, then click on the Drop-Down List Box Properties
2011-03-23-BrowserBasedInfopath-13.png
On the next dialog, make sure your choices look like the ones I have highlighted below. Note that I have checked off the “Show only entries with unique display names.”
2011-03-23-BrowserBasedInfopath-14.png
At this point you can preview the form in InfoPath and see that the first list box is fully operational:
2011-03-23-BrowserBasedInfopath-15.png
Step 6: We are now ready to setup the City drop-down. Bring up the properties dialog for the City drop-down.
2011-03-23-BrowserBasedInfopath-16.png
We will need to make a few adjustments.
Step 6a) For the List Box choices, pick Get choices from an external data source.
Step 6b) For the Data Source, pick States.
Step 6c) Click on the xPath (2011-03-23-BrowserBasedInfopath-17.png) icon to the right of Entries.
Step 6d) Open the dataFields folder and select the item in the folder. Then click on Filter Data…
2011-03-23-BrowserBasedInfopath-18.png
Step 6e) Click on Add
2011-03-23-BrowserBasedInfopath-19.png
Step 6f) make sure Title is selected on the left, then “is equal to”, then pull down the drop-down on the right
2011-03-23-BrowserBasedInfopath-20.png
Step 6g) Pick Select a field or group…
2011-03-23-BrowserBasedInfopath-21.png
Step 6h) On the top, change the drop down from States (Secondary) to Main
2011-03-23-BrowserBasedInfopath-22.png
2011-03-23-BrowserBasedInfopath-23.png
Step 6i) Pick State
2011-03-23-BrowserBasedInfopath-24.png
Click OK, until you are back at the beginning. Now you can preview the form and it works almost perfectly!
2011-03-23-BrowserBasedInfopath-25.png
There is one tiny issue! The city drop down does not clear itself. Therefore if you pick another state, the old city will stay the same as the one you had picked in the earlier pick of the city.
2011-03-23-BrowserBasedInfopath-26.png
We must add a rule to clear the City. This leads us to step 7
Step 7a) Select the City drop-down, and click on the Mange Rules icon in the Home Ribbon
2011-03-23-BrowserBasedInfopath-27.png
Step 7b) Click on the New on the right side
2011-03-23-BrowserBasedInfopath-28.png
Step 7c) Pick Action
2011-03-23-BrowserBasedInfopath-29.png
Step 7d) Click on Set a field’s value
2011-03-23-BrowserBasedInfopath-30.png
Step 7e) Set a field’s value, and then pick City for the field. Leave the Value blank.
2011-03-23-BrowserBasedInfopath-31.png
2011-03-23-BrowserBasedInfopath-32.png
2011-03-23-BrowserBasedInfopath-33.png
Hit OK , and you are done!
You should now have a fully functioning cascading drop-down set of lists.

Tuesday, March 27, 2012

Create Form Based Authentication-FBA(SQL Membership)

To create form based authentication,we have to create the site as claim based authentication.
First create that site with windows authentication.
Step1:Create a db for membership user, roles and etc., by execute this exe “C:\Windows\Microsoft.NET\Framework\v2.0.50727”-asnet_regsql
Step2:We have to do changes in 3 web.config files
   1.site’s web.config
  2.central admin’s web.config
 3.webservice’s  web.config (we can find this from iis we can find “sharepoint web services”site , by exploring that site can get we.config of the webservice site).
Replace membership and rolemanager tag with following code

    <membership defaultProvider="FBAMembership">
      <providers>
        <add name="FBAMembership" connectionStringName="AspNetSqlProvider" applicationName="/"  type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0,  Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </providers>
    </membership>
    <roleManager enabled="true"
                                  defaultProvider="FBARoles">
      <providers>
        <add name="FBARoles"
                                  connectionStringName="AspNetSqlProvider"
                                  applicationName="/"
                                  type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </providers>
    </roleManager>

Step3:Add connection string to that 3 web.config files
By adding the following codeLChange connection string to your DB.
<connectionStrings>
    <add connectionString="Data Source=SP4\SQLEXPRESS;Initial Catalog=fbaDB;Integrated Security=True" name="AspNetSqlProvider" />
  </connectionStrings>

Step4: Make sure that , defaultProvider is AspNetWindowsTokenRoleProvider and enabled true

<roleManager defaultProvider="AspNetWindowsTokenRoleProvider" enabled="true">


Step5:change that site to FBA
In central admin –manage web application-select that site and choose-Authentication Provider

It ll give you a popup

Select and change the default authentication provider

Step6:ASP.NET Memership provider name: FBAMembership and ASP.NET Role Provider Name:FBARoles
And save that.
Step7: create some users in that membershipDB
          1.Create a webapplication(asp.net site in VS2010)
          2.configure membership DB for that
         Ie) add connectiostring for your membershipDB
In <connectionstrings> tag paste this code
<add name="ApplicationServices" connectionString="data source=sp4\SQLEXPRESS;Initial Catalog=fbaDB; Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
  

And configure membership database  again  ,create users(Don’t enable roles for this site)
Step8: change site collection administrator to your Membership user(created in step7)

Step9: Login by Using Form Based Authentication

Friday, March 23, 2012

WebService in Sharepoint 2010

How to Create an ASMX Web Service on SharePoint 2010, Using Visual Studio 2010



Back in SharePoint 2007, asmx web services were quite prevalent, thanks to the WSPBuilder tool, and it’s templates.   They are useful for executing actions between multiple web applications and can be used by client applications, as well.  Furthermore, InfoPath forms, deployed to SharePoint, could also use these asmx web services.

Unfortunately, Visual Studio 2010 did not come with a template for SharePoint web services.  So, today I will be writing about how we can create asmx web services for SharePoint 2010.  All you will need is SharePoint 2010.

First, start a new Empty SharePoint 2010 project.  I will call this SPASMXService.


Make sure to deploy it as a farm solution.


 First, you need to close this project by right clicking on the project and then selecting ‘unload project’.



Then, right click on the project again, and select, ‘Edit SPASMXService’.


Under <SandboxedSolution>False</SandboxedSolution> type in:

<TokenReplacementFileExtensions>asmx</TokenReplacementFileExtensions>

This will be the result:


 Then, save and close out of this xml file.  This will allow Visual Studio to insert the solution information where necessary.  Therefore, this is a crucial step!  Finally, reload the project file.




Next, we will be creating the web service.  Right click on the project, and select “Add” and then select “New Class…”  This will be the code behind.  Let’s just call this SPASMXService.cs.





Now, open SPASMXService.cs, and make the following changes:

 


This is a good start for a web service with a web method.  Now, of course we have a few errors because we still have not brought in the necessary libraries.  Right click on ‘references’ in the Solution Explorer, and select, ‘Add Reference’.  Select System.Web.Services from the .NET tab.  Then, in SPASMXService.cs, add, ‘using System.Web.Services’.  This should look like this:






Finally, we have to create the service page.  I like to keep it in the _layouts folder, but you can keep it elsewhere using similar steps.  Right click on the project item in the solution explorer, and select add -> SharePoint “Layouts” Mapped Folder.




You can also select SharePoint Mapped Folder, and then select ISAPI.  This would cause the page to go into _vti_bin instead.

For now, I’m going to stick to _layouts:






The SPASMXService folder was automatically made.  Nice.


Inside the SPASMXService, under Layouts, we will add a new file of type xml.  We Shall call it SPASMXService.asmx.








The contents of SPASMXService.asmx will be a single line:

 <%@ WebService Language="C#" Debug="true" Class="[Class path], $SharePoint.Project.AssemblyFullName$"  %>

 Where [class path] is the full namespace name of the SPASMXService class in SPASMXService.cs.  In my case, the line will be:



 From:

 

 Finally, save everything, and then deploy the solution.





If everything went right, you should see this using Internet Explorer:




If you used ISAPI instead of Layouts, _layouts in that screenshot should be _vti_bin, instead.  If you opened this from a front end server with web service, then you can further test this web service by clicking on that link.



Lastly, a bit of trouble shooting; you can check on the web service page by going to:



C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS



If you used ISAPI instead of LAYOUTS, then instead go to:



C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI



If the web service does not load on Internet explorer, then you should open the asmx page from one of these two locations.  If you open the asmx page from one of these two locations, and you still find “$SharePoint.Project.AssemblyFullName$”, then you need to go back to the top of this article and follow the steps regarding unloading and reloading the project.

Creating Provider hosted app (sharepoint online) with local hosted IIS

The Pre-requires are as follows. 1. Office 365 Subscription 2. Visual Studio 2015 (Professional/Community/Enterprise Edition) With t...