Wednesday 10 October 2012

Sample Page Layout .aspx file code


<%@ 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">
  <!--- End Menu -->
   
            <div style="width:500px">
                <WebPartPages:WebPartZone runat="server" Title="TitleZone" ID="TitleZone" ><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>      
            </div>
     
    <!--- End Banner -->
 
     
<WebPartPages:WebPartZone runat="server" Title="RightZone" ID="RightZone"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
             
     
        <!--- End Cnt -->

</asp:Content>

Element File content


This element file is used to create a page layout with default webpart in the wepart layout...




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

  <Module Name="CustomLayouts" List="116"  Url="_catalogs/masterpage">

    <File Path="CustomLayouts\Blackintonfaq.aspx" Url="Blackintonfaq.aspx" IgnoreIfAlreadyExists="TRUE" Type="GhostableInLibrary">

      <!--<AllUsersWebPart WebPartZoneID="TitleZone" WebPartOrder="1">

        <![CDATA[

        <webParts>
        <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
          <metaData>
            <type name="BlackInTon.Title.Title, BlackInTon, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2754d9471101933f" />
            <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
          </metaData>
          <data>
            <properties>
              <property name="Title" type="string">Title</property>
              <property name="Description" type="string">My Visual WebPart</property>
              <property name="ChromeType" type="chrometype">None</property>
            </properties>
          </data>
        </webPart>
      </webParts>
      
      ]]>
       



    </File>
 </Module>

Change the webpart as your wish...

Tuesday 18 September 2012

Some times you cant deploy or retract the sloution in the solution managemetn

The administration service is running so all administration jobs will be run in
the timer service.


Symptom:

I had a solution that was stuck in the deploying state.  When I looked at it, it had only deployed successfully on one the the front ends.  To solve the problem, I ran stsadm execadmjobs.  I have done this multiple times in 2007, but this time I got this message:

The administration service is running so all administration jobs will be run in the timer service.

Problem:

The timer service is set to take care of all admin tasks, so it is telling you that the jobs will run when the timer service is good and ready to kick them off, but until then, just sit on your hands and wait.

Solution:

Stop the admin service, then run the command to execute the admin jobs, then turn back on the admin service.  These are the three powershell commands to do this:
 •net stop SPAdminV4
•Start-SPAdminJob
•net start SPAdminV4

The first command shuts off the admin service.  The second command is the powershell equivalent to stsadm execadmjobs and the third one turns back on the admin service.

Monday 17 September 2012

Custom master page in SharePoint 2010 using VS 2010

Steps to create a custom master page in sharepoint 2010 using VS2010
  1. Create an empty SharePoint Solution
  2. Add a Module in the Project ( module name branding )
  3. Add a master page(master page name mymaster)
  4. Add the content in the master page
  5. Change the Element file as following 
<?xml version="1.0" encoding="utf-8"?><Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="brading">
  <File Path="brading\mymaster.master" Url="brading/mymaster.master" /></Module></Elements>

Url  ---->  it create the folder structure  exampl branding /mymaster creates the mymaster file inside the branding folder
  1. Add the event receiver as follows to change the master page at the time of feature activated 
    and change the default master page at at the time of feature deactivated
    
    
    // Uncomment the method below to handle the event raised after a feature has been activated.public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        SPWeb currentWeb = (SPWeb)properties.Feature.Parent;
    
        currentWeb.MasterUrl = "/_catalogs/masterpage/mymaster.master";
        currentWeb.CustomMasterUrl = "/_catalogs/masterpage/mymaster.master";
        currentWeb.Update();
    }
    
    // Uncomment the method below to handle the event raised before a feature is deactivated.public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
    {
        SPWeb currentWeb = (SPWeb)properties.Feature.Parent;
    
        currentWeb.MasterUrl = "/_catalogs/masterpage/nightandday.master";
        currentWeb.CustomMasterUrl = "/_catalogs/masterpage/nightandday.master";
        currentWeb.Update();
    }
     
     
    Please note this is for the Site master no need to made much changes in the system master page.
    Just change the logo of the master page that is enough. 
     

Run Commands in Windows

Program Run Command

Accessibility Controls = access.cpl

Accessibility Wizard = accwiz
Add Hardware Wizard = hdwwiz.cpl
Add/Remove Programs = appwiz.cpl
Administrative Tools = control admintools
Adobe Acrobat ( if installed ) = acrobat
Adobe Distiller ( if installed ) = acrodist
Adobe ImageReady ( if installed ) = imageready
Adobe Photoshop ( if installed ) = photoshop
Automatic Updates = wuaucpl.cpl
Basic Media Player = mplay32
Bluetooth Transfer Wizard = fsquirt

Calculator = calc
Ccleaner ( if installed ) = ccleaner
C: Drive = c:
Certificate Manager = cdrtmgr.msc
Character Map = charmap
Check Disk Utility = chkdsk
Clipboard Viewer = clipbrd
Command Prompt = cmd
Command Prompt = command
Component Services = dcomcnfg
Computer Management = compmgmt.msc
Compare Files = comp
Control Panel = control
Create a shared folder Wizard = shrpubw

Date and Time Properties = timedate.cpl
DDE Shares = ddeshare
Device Manager = devmgmt.msc
Direct X Control Panel ( if installed ) = directx.cpl
Direct X Troubleshooter = dxdiag
Disk Cleanup Utility = cleanmgr
Disk Defragment = dfrg.msc
Disk Partition Manager = diskmgmt.msc
Display Properties = control desktop
Display Properties = desk.cpl
Display Properties (w/Appearance Tab Preselected ) = control color
Dr. Watson System Troubleshooting Utility = drwtsn32
Driver Verifier Utility = verifier

Ethereal ( if installed ) = ethereal
Event Viewer = eventvwr.msc
Files and Settings Transfer Tool = migwiz
File Signature Verification Tool = sigverif
Findfast = findfast.cpl
Firefox = firefox
Folders Properties = control folders
Fonts = fonts
Fonts Folder = fonts
Free Cell Card Game = freecell

Game Controllers = joy.cpl
Group Policy Editor ( xp pro ) = gpedit.msc
Hearts Card Game = mshearts
Help and Support = helpctr
Hyperterminal = hypertrm
Hotline Client = hotlineclient

Iexpress Wizard = iexpress
Indexing Service = ciadv.msc
Internet Connection Wizard = icwonn1
Internet Properties = inetcpl.cpl
Internet Setup Wizard = inetwiz
IP Configuration (Display Connection Configuration) = ipconfig /all
IP Configuration (Display DNS Cache Contents) = ipconfig /displaydns
IP Configuration (Delete DNS Cache Contents) = ipconfig /flushdns
IP Configuration (Release All Connections) = ipconfig /release
IP Configuration (Renew All Connections) = ipconfig /renew
IP Configuration (Refreshes DHCP & Re-Registers DNS) = ipconfig /registerdns
IP Configuration (Display DHCP Class ID) = ipconfig /showclassid
IP Configuration (Modifies DHCP Class ID) = ipconfig /setclassid

Java Control Panel ( if installed ) = jpicpl32.cpl
Java Control Panel ( if installed ) = javaws
Keyboard Properties = control keyboard

Local Security Settings = secpol.msc
Local Users and Groups = lusrmgr.msc
Logs You Out of Windows = logoff

Malicious Software Removal Tool = mrt
Microsoft Access ( if installed ) = access.cpl
Microsoft Chat = winchat
Microsoft Excel ( if installed ) = excel
Microsoft Diskpart = diskpart
Microsoft Frontpage ( if installed ) = frontpg
Microsoft Movie Maker = moviemk
Microsoft Management Console = mmc
Microsoft Narrator = narrator
Microsoft Paint = mspaint
Microsoft Powerpoint = powerpnt
Microsoft Word ( if installed ) = winword
Microsoft Syncronization Tool = mobsync
Minesweeper Game = winmine
Mouse Properties = control mouse
Mouse Properties = main.cpl
MS-Dos Editor = edit
MS-Dos FTP = ftp

Nero ( if installed ) = nero
Netmeeting = conf
Network Connections = control netconnections
Network Connections = ncpa.cpl
Network Setup Wizard = netsetup.cpl
Notepad = notepad
Nview Desktop Manager ( if installed ) = nvtuicpl.cpl

Object Packager = packager
ODBC Data Source Administrator = odbccp32
ODBC Data Source Administrator = odbccp32.cpl
On Screen Keyboard = osk
Opens AC3 Filter ( if installed ) = ac3filter.cpl
Outlook Express = msimn

Paint = pbrush
Password Properties = password.cpl
Performance Monitor = perfmon.msc
Performance Monitor = perfmon
Phone and Modem Options = telephon.cpl
Phone Dialer = dialer
Pinball Game = pinball
Power Configuration = powercfg.cpl
Printers and Faxes = control printers
Printers Folder = printers
Private Characters Editor = eudcedit

Quicktime ( if installed ) = quicktime.cpl
Quicktime Player ( if installed ) = quicktimeplayer

Real Player ( if installed ) = realplay
Regional Settings = intl.cpl
Registry Editor = regedit
Registry Editor = regedit32
Remote Access Phonebook = rasphone
Remote Desktop = mstsc
Removable Storage = ntmsmgr.msc
Removable Storage Operator Requests = ntmsoprq.msc
Resultant Set of Policy ( xp pro ) = rsop.msc

Scanners and Cameras = sticpl.cpl
Scheduled Tasks = control schedtasks
Security Center = wscui.cpl
Services = services.msc
Shared Folders = fsmgmt.msc
Sharing Session = rtcshare
Shuts Down Windows = shutdown
Sounds Recorder = sndrec32
Sounds and Audio = mmsys.cpl
Spider Solitare Card Game = spider
SQL Client Configuration = clicongf
System Configuration Editor = sysedit
System Configuration Utility = msconfig
System File Checker Utility ( Scan Immediately ) = sfc /scannow
System File Checker Utility ( Scan Once At Next Boot ) = sfc /scanonce
System File Checker Utility ( Scan On Every Boot ) = sfc /scanboot
System File Checker Utility ( Return to Default Settings) = sfc /revert
System File Checker Utility ( Purge File Cache ) = sfc /purgecache
System File Checker Utility ( Set Cache Size to Size x ) = sfc /cachesize=x
System Information = msinfo32
System Properties = sysdm.cpl

Task Manager = taskmgr
TCP Tester = tcptest
Telnet Client = telnet
Tweak UI ( if installed ) = tweakui
User Account Management = nusrmgr.cpl
Utility Manager = utilman

Volume Serial Number for C: = label
Volume Control = sndvol32
Windows Address Book = wab
Windows Address Book Import Utility = wabmig
Windows Backup Utility ( if installed ) = ntbackup
Windows Explorer = explorer
Windows Firewall = firewall.cpl
Windows Installer Details = msiexec
Windows Magnifier = magnify

Windows Management Infrastructure = wmimgmt.msc
Windows Media Player = wmplayer
Windows Messenger = msnsgs
Windows Picture Import Wizard (Need camera connected) = wiaacmgr
Windows System Security Tool = syskey
Windows Script host settings = wscript
Widnows Update Launches = wupdmgr
Windows Version ( shows your windows version ) = winver
Windows XP Tour Wizard = tourstart
Wordpad = write
Zoom Utility = igfxzoom

Friday 27 July 2012

The request failed with HTTP status 417: Expectation failed when SharePoint calling .asmx web service

I tried to access a web method in a .asmx web service from SharePoint web service.
To add a web reference steps
  1. Add Service Reference
  2. Click Advance button in the window
  3. Click Add Web Reference in the next window
  4. Then paste the asmx path add give a reference name then click ok
After this I tried to call the web method but it gives the  The request failed with HTTP status 417 error  I tried with Google finally I found a link in Code Project
http://www.codeproject.com/Articles/94235/The-request-failed-with-HTTP-status-417-Expectatio

Steps to Resolve
  • We need to have this line of code before making any web requests:  
         System.Net.ServicePointManager.Expect100Continue = false
 
  • Add these lines to the application's configuration file (between <configuration> and </configuration>): 
     
    <system.net>
     <settings>
      <servicePointManager expect100Continue="false" />
     </settings>
    </system.net>
     
     
    Now Everything goes fine.
     
    Happy Coding :)  

Saturday 21 July 2012

Send mail using GMail SMTP

  

try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {

                    bool isAllowed = SPContext.Current.Web.AllowUnsafeUpdates;
                    SPContext.Current.Web.AllowUnsafeUpdates = true;
                    SmtpClient smtp;
                    MailMessage mail = new MailMessage();
                    string FromEmail = "s.sugunthan.mca@gmail.com";
                    string EmailPwd = "password";
                    smtp = new SmtpClient("smtp.gmail.com");
                    smtp.UseDefaultCredentials = true;
                    smtp.Host = "smtp.gmail.com";
                    smtp.Port = 587;
                    smtp.Credentials = new System.Net.NetworkCredential(FromEmail, EmailPwd);
                    smtp.EnableSsl = true;
                    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                    mail.Body = "Sample Content";
                    mail.To.Add(new MailAddress("sugunthan@gmail.com"));
                    mail.From = new MailAddress(FromEmail);
                    //Bybass the certifiate check
                    ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
                    smtp.Send(mail);
                    SPContext.Current.Web.AllowUnsafeUpdates = isAllowed;
                    ClearFields();
                    Clear_ErrorMsg();
                    lblResult.ForeColor = Color.Green;
                    lblResult.Text = "Mail Send Successfully!!";





                });
            }
            catch (Exception)
            {
                lblResult.ForeColor = Color.Red;
                lblResult.Text = "Sorry! Please Try Again!!";
            }

Email Validation in the C# code behind


  string pattern=@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
                System.Text.RegularExpressions.Match match =
                     Regex.Match(txtEmail.Text.Trim(), pattern, RegexOptions.IgnoreCase);

                if (match.Success)
                {
                }
                else
                {
                }

Wednesday 11 July 2012

Error in using list view control in SharePoint 2010 visual webpart

Hi Tried to add a list view control in the SharePoint 2010 visual webpart but it give the error like following.


Line 8:  <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="BlogListUserControl.ascx.cs" Inherits="BlackintonWebparts.BlogList.BlogListUserControl" %>
Line 9: 
Line 10: <asp:ListView ID="ListViewProducts" runat="server" ItemPlaceholderID="ProductItem">
Line 11:     <ItemTemplate>
Line 12:

After that I found the namespace is not register so I register the name space

Add the following code under the <controls> section under <system.web> and pages in the webcofig file
 
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />



Or add in the ascx file or aspx file



<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>


Happy coding :))