Wednesday, 21 August 2013

SPSiteDataQuery Share Point 2010 example

http://thesharepoint2010.wordpress.com/2012/10/01/spsitedataquery-share-point-example/

SPSiteDataQuery is used to retrieve data from list or from all list in the site collection ( i.e. used for cross-site and cross-list queries). SPWeb.GetSiteData is used to retrieve the data.
SPSiteDataQuery.Webs property will be used to specify from where the data will be retrieved
Following properties will be used
1
2
3
dataQuery.Webs = "<Webs Scope=\"Recursive\">";
dataQuery.Webs = "<Webs Scope=\"SiteCollection\">";
dataQuery.Webs = "<Webs Scope=\"\">";
Following example illustrate that the data is retrieve from the Document library (ServerTemplate for Document library is 101).In this example document No is used in the where clause .SPSiteDataQuery object is passed to the GetSiteData and then result is bind to the Grid view.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
string siteStr = SPContext.Current.Web.Url;
 
            using (SPSite site = new SPSite(siteStr))
            {
                using (SPWeb web = site.RootWeb)
                {
                    SPSiteDataQuery dataQuery = new SPSiteDataQuery();
                    dataQuery.Webs = "<Webs Scope=\"Recursive\">";
                    dataQuery.Lists = "<Lists ServerTemplate=\"101\" />";
                    dataQuery.ViewFields = "<FieldRef Name=\"DocumentNo\"/>" + "<FieldRef Name=\"Title\" />" + "<FieldRef Name=\"Tags\" />" + "<FieldRef Name=\"FileRef\" />";
                    string where = "";
 
                    where = "<Where>";
                     
                    if (txtDocumentNo.Text != "")
                    {
                        where += "<Eq>";
                        where += "<FieldRef Name=\"DocumentNo\"/>";
                        where += "<Value Type='Text'>" + txtDocumentNo.Text + "</Value>";
                        where += "</Eq>";
                    }
 
 
                    where += "</Where>";
                    dataQuery.Query = where;
                    DataTable dt = web.GetSiteData(dataQuery);
                    DataView dv = new DataView(dt);
                    gvResult.DataSource = dv;
                    gvResult.DataBind();
                     
                }

Thursday, 27 June 2013

step-by-step guide to setup and configure Adobe PDF file search in SharePoint 2010.


PDF in SharePoint 2010


Step 1
Download the Adode iFilter from the following url.
http://www.adobe.com/support/downloads/detail.jsp?ftpID=4025
image
Step 2 Download the pdf icon file. Download a 16*16 gif or a png file. Or else you can download it from the below url.http://www.adobe.com/misc/linking.html
Step 3 Extract the zip file and install the PDFFilter64installer file which you downloaded in Step 1.
Step 4 Open the “Run” window and open Registry Editor running the regedit command.
image

In Registry editor browse to location \\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\ContentIndexCommon\Filters\Extension
image
Step 5 Right Click on “Extension” and add a new Key.
image
Name it as .pdf.
Step 6 Now add the following GUID as the default key.
{E8978DA6-047F-4E3D-9C78-CDBE46041603}
image
Step 7 Now is the time to set the icon for pdf files.
Copy/Move the pdf icon you downloaded in in Step 2 to the following folder.
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES
Next open “Internet Information Services (IIS) Manager and Stop the service.
image
This step is required as you are going to amend a file which is currently in use.
Step 8 Browse to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML and open the DOCICON.XML file. (use Notepad). And do a search for the <ByExtension> tag.
image
Add the line <Mapping Key="pdf" Value="pdficon_small.gif" />
(replace pdficon_small.gif with your icon name)
image
Save the file.
Start IIS Service
Step 9 Open SharePoint Central Administration. Under Application Management select Manage Service Applications. Open Search Service Application.
image
Step 10 Select File Types on the left menu. Click New File Type. Enter pdf and click OK. Smile
image
Step 11 Click on Content Sources and do a Full Crawl (not an Incremental Crawl). After completing job, you know what to do. Smile with tongue out Do a search.
image

Tuesday, 9 April 2013

SharePoint - 2010 Add the Header Name in DIV in MOSS 2010

<div class="my-customdiv">
Growth & Business Planning Proposal</div><style>.my-customdiv{
background-color: #4ba614;
border-bottom: 4px #FFF solid;
text-align: left;
color: #FFF;
font-size: 10pt;
font-weight: bold;
padding: 10px;
height: 30px;}

</style>

SharePoint 2010-2013 Best Link

SharePoint 2010 – Base CSS classes / names

SharePoint 2010 – How to open PopUp Dialog in SharePoint Site ?

<script type="text/javascript">

// function OpenWindow(title, url) {// // var options = { url: url, width: 1000, height: 800, title: title };// SP.UI.ModalDialog.showModalDialog(options); // return false;// }
//User Defined Function to Open Dialog Frameworkfunction OpenDialog(strPageURL) {
var dialogOptions = SP.UI.$create_DialogOptions();dialogOptions.url = strPageURL;
// URL of the PagedialogOptions.width = 750; // Width of the DialogdialogOptions.height = 500; // Height of the Dialog// dialogOptions.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback); // Function to capture dialog closed eventSP.UI.ModalDialog.showModalDialog(dialogOptions); // Open the Dialogreturn false;}

// Dialog close event capture functionfunction CloseCallback(strReturnValue, target) {
if (strReturnValue === SP.UI.DialogResult.OK) // Perform action on Ok.{
alert(
"User clicked Ok!");}

if (strReturnValue === SP.UI.DialogResult.cancel) // Perform action on Cancel.{
alert(
"User clicked Cancel!");}
}
 

</script>

//Open at OnClientclick event
<td align="left" colspan="4"><asp:Button ID="btnRemarksHistory" runat="server" Text="Remarks" CssClass="sbtn"OnClientClick="return OpenDialog('/_Layouts/GrowthApp/GrowthRemarks.aspx');" /> <%
--OnClick="btnRemarksHistory_Click"--%></td>

Yaah

//Open at OnClick event
<td align="left" colspan="4">
<asp:Button ID="Button1" runat="server" Text="Remarks" CssClass="sbtn"OnClick="btnRemarksHistory_Click"/>  </td>protected void btnRemarksHistory_Click(object sender, EventArgs e){

string str = SPContext.Current.Site.Url;
btnRemarksHistory.Attributes.Add(
"onclick", "return OpenDialog('/_layouts/GrowthApp/GrowthRemarks.aspx')");
}