Sunday, 21 February 2016

Show XSLT in Table Format new Template

<Xsl>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
              exclude-result-prefixes="msxsl" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method='html' indent='yes'/>
  <xsl:template match='dsQueryResponse' xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">

<table id="tbl1" cellpadding="0" cellspacing="0" border="0" style="padding:0px;" class="tableRound" width="1000px">
<tr>
<td style="width:1000px">
<div style="width:1000px; position:relative;vertical-align:top;">
<xsl:apply-templates select='Rows/Row'/>
</div></td></tr>
</table>
</xsl:template>


<xsl:template match='Row'>


<div style="float:left; vertical-align:top; background-color:transparent; width:180px; height:70px; padding-bottom:0px;">
<div style="float:left; width:150px;">

<a class="className" target="_blank">
<xsl:attribute name="href">
<xsl:value-of select="@URL"></xsl:value-of>
</xsl:attribute>
<xsl:value-of select="@URL.desc"></xsl:value-of>
</a>


</div>
</div>

</xsl:template>

</xsl:stylesheet></Xsl>

Send an email with attachment from sharepoint List/Library

using System.Net.Mail;
using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                     
                        MailMessage message = new MailMessage();
                        //Get the Sharepoint SMTP information from the //SPAdministrationWebApplication
                        message.From = new MailAddress(SPAdministrationWebApplication.Local.OutboundMailSenderAddress.ToString());
                        message.To.Add(new MailAddress("user@gmail.com"));
                        message.IsBodyHtml = true;
                       //Set the subject and body of the message
                        message.Body = "Hi there, check out the attachment";
                        message.Subject = "Sent Attachment";
                        //Get the Document Library from where you want to sed the attachment
                        SPList library = web.Lists["MyDocuments"];
                        //Get the Url of the file to be sent as an attachment
                        string strUrl = "http://siteUrl/MyDocuments/Configuring Database Mial  SQL server 2008.doc";
                        //Get the file to be sent as an attachment
                        SPFile file = library.ParentWeb.GetFile(strUrl);
                        //Add the attachment
                        message.Attachments.Add(new Attachment(file.OpenBinaryStream(), file.Name));
                         //Create the SMTP client object and send the message
                        SmtpClient smtpClient = new SmtpClient(SPAdministrationWebApplication.Local.OutboundMailServiceInstance.Server.Address);
                        smtpClient.Send(message);


                        web.AllowUnsafeUpdates = false;
                    }

Send Mail Using Sharepoint Utilities

using Microsoft.SharePoint.Utilities;
using System.Collections.Specialized;

public void SendMailUsingUtility(SPWeb web)
        {
            StringDictionary headers = new StringDictionary();
            headers.Add("to", "abc@abc.com");
            headers.Add("cc", "abc@abc.com");
            headers.Add("bcc", "abc@abc.com");
            headers.Add("from", "abc@abc.com");
            headers.Add("subject", "Mail Using Utility");
            headers.Add("content-type", "text/html");

            string bodyText = "body text goes here !";

            SPUtility.SendEmail(web, headers, bodyText.ToString());
        }

remove ribbon in sitepage in popup

 <style type="text/css">
    .ms-dialog #s4-ribbonrow, .ms-dialog .ms-cui-topBar2, .ms-dialog .s4-notdlg, .ms-dialog .s4-pr s4-ribbonrowhidetitle, .ms-dialog .s4-notdlg noindex, .ms-dialog #ms-cui-ribbonTopBars, .ms-dialog #s4-titlerow, .ms-dialog #s4-pr s4-notdlg s4-titlerowhidetitle, .ms-dialog #s4-leftpanel-content {display:none !important;}
    .ms-dialog .s4-ca{margin-left:0px !important; margin-right:0px !important;}
    </style>

Refresh Page After Submition Popup




<script>
var pathh='/Lists/ListName/Item/newifs.aspx';

function ShowDialog()
{

var options = {
url:pathh,
autoSize:true,
allowMaximize:true,
title: 'RequestName',
showClose: true,
 dialogReturnValueCallback:Function.createDelegate(null, CloseCallback)
};

var dialog = SP.UI.ModalDialog.showModalDialog(options);
}
function CloseCallback(result, target) {
        location.reload(true);
    }
</script>
<a href="javascript:ShowDialog()">Add New Request</a>










put alternate color row wise on condition base in LiView Webpart

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("makeAlternateColor()");

function makeAlternateColor()
{
var table = document.getElementById("Dashboard"); //Get the SharePoint List view's Table id using Firebug or IE Developer Toolbar's help and replace "Dashboard". Otherwise this code wont work!
var rows = table.getElementsByTagName("tr");
//manipulate rows
for(i = 0; i < rows.length; i++)
{
if(i % 2 == 0)
{
rows[i].className = "even";
}else
{
rows[i].className = "odd";
}
}
}
</script>
<style type="text/css">
.odd
{
background-color: white;
}
.even
{
background-color: yellow;
}
</style>

Create a DashBoard Using XSLT with Statuswise Count to Assignee

<Xsl>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
             exclude-result-prefixes="msxsl" xmlns:ddwrt2="urn:frontpage:internal">

<xsl:output method='html' indent='yes'/>
<xsl:key name="Grouping" match="Row" use="@AssignedTo.id" />

<xsl:template match='dsQueryResponse' xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">


<table id="tbl1" cellpadding="10" cellspacing="0" border="0" style="padding:0px;" class="tableRound">
<xsl:apply-templates select='Rows/Row'/>
</table>
</xsl:template>
<xsl:template match='/' xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
<tr>
<td style="font-weight:bold; color:#002276">Assign To</td>
<td style="font-weight:bold; color:#002276">Completed</td>
<td style="font-weight:bold; color:#002276">In Progress</td>
<td style="font-weight:bold; color:#002276">Not Started</td>
<td style="font-weight:bold; color:#002276">Waiting on someone else</td>
</tr>

<xsl:for-each select="/dsQueryResponse/Rows/Row[generate-id(.)=generate-id(key('Grouping',@AssignedTo.id))]/@AssignedTo.id">
<xsl:sort />

<tr>

<td width="58%"><xsl:value-of select="key('Grouping',.)/@AssignedTo" disable-output-escaping="yes" /></td>
<td width="10%"><xsl:value-of select="count(key('Grouping',.)[@Status='Completed'])" disable-output-escaping="yes"></xsl:value-of></td>
<td width="10%"><xsl:value-of select="count(key('Grouping',.)[@Status='In Progress'])" disable-output-escaping="yes"></xsl:value-of></td>
<td width="10%"><xsl:value-of select="count(key('Grouping',.)[@Status='Not Started'])" disable-output-escaping="yes"></xsl:value-of></td>
<td width="10%"><xsl:value-of select="count(key('Grouping',.)[@Status='Waiting on someone else'])" disable-output-escaping="yes"></xsl:value-of></td>



</tr>

</xsl:for-each>  

</xsl:template>
</xsl:stylesheet></Xsl>

Open and Close A Model Popup in sharepoint

For Open A PoPUp
<a href="javascript:SP.UI.ModalDialog.ShowPopupDialog('/sitPages.aspx', null, 500, 300);" >
Edit
 </a>

javascript:SP.UI.ModalDialog.ShowPopupDialog('PAgeAddress.aspx?ID={$thisNode/@TRFId}', null, 1000, 800);

javascript:OpenPopUpPageWithTitle('/SitePages/LeaderMessage.aspx',null,null,null,'Leader Message');


and Close A PoPUp from code behinde

public void CloseForm()
        {
            HttpContext context = HttpContext.Current;
            if (HttpContext.Current.Request.QueryString["IsDlg"] != null)
            {
                context.Response.Write("<script type='text/javascript'>window.frameElement.commitPopup()</script>");
                context.Response.Flush();    
                context.Response.End();
            }
        }

Saturday, 20 February 2016

left quick bar menubar styles


.s4-ql UL.root > LI > .menu-item {

PADDING-BOTTOM: 2px;
BORDER-RIGHT-WIDTH: 0px;
OVERFLOW-X: hidden;
TEXT-TRANSFORM: capitalize;
MARGIN: 0px; MIN-HEIGHT: 19px;
 PADDING-LEFT: 10px;
 PADDING-RIGHT: 4px;
 FONT-FAMILY: Arial, Helvetica, sans-serif;
  WORD-WRAP: break-word;
   BORDER-TOP-WIDTH: 0px;
    COLOR:white;
    FONT-SIZE: 12px;
    font-weight: normal;
     BORDER-LEFT-WIDTH: 0px;
     PADDING-TOP: 8px;
        background-color:#3c8a2e;
        border-bottom:1px white solid;
}
.s4-ql UL.root > LI > .menu-item:hover{
background:#cee2cb;
color:#000;
}

BODY #s4-leftpanel {
MARGIN-TOP: 25px;
WIDTH: 150px;
 FLOAT: left;
  MARGIN-LEFT: 5px;
  border-bottom:1px #002776 dotted;
}
BODY #s4-leftpanel-content {
border:none;
}
.s4-ql UL.root UL > LI > A{
 border-bottom:1px dotted;
border-bottom-color:black;

}



How to set multiUserValueCollection in SPFieldUserValueCollection




public SPFieldUserValue ConvertLoginAccount(string userid)
        {
            SPFieldUserValue uservalue;
            using (SPSite site = new SPSite(SPContext.Current.Web.Url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPUser requireduser = web.EnsureUser(userid);
                    uservalue = new SPFieldUserValue(web, requireduser.ID, requireduser.LoginName);
                }
            }
            return uservalue;
        }


//user collection in array
string[] userarray = lblFunctionTeam.Text.ToString().Split(';');

                                SPFieldUserValueCollection usercollection = new SPFieldUserValueCollection();
                                for (int i = 0; i < userarray.Length - 1; i++)
                                {
                                    SPFieldUserValue usertoadd = ConvertLoginAccount(userarray[i]);
                                    usercollection.Add(usertoadd);
                                }
                  //set multiuserCollection
                                item["UserCollectionField"] = usercollection;
//single user Value
  SPFieldUserValue usertoadd1= ConvertLoginAccount("userIdentityEmailOrLoginName");
    item["UserField"] =usertoadd1;