Archive

Archive for October, 2012

Sharepoint Tree View All list and sites


using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using System.Web;

namespace SampleWebPart.VisualWebPart1
{
public partial class VisualWebPart1UserControl : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
SPWeb thisWeb = null;
TreeNode node;
thisWeb = SPContext.Current.Web;
//Add the Web’s title as the display text for the tree node, and add the URL as the NavigateUri.
node = new TreeNode(thisWeb.Title, null, null, thisWeb.Url, “_self”);
//The Visual Web Part has a treeview control called siteStructure.
siteStructure.Nodes.Add(node);
//Get a reference to the current node, so child nodes can be added in the correct position.
TreeNode parentNode = node;
//Iterate through the Lists collection of the Web.
foreach (SPList list in thisWeb.Lists)
{
if (!list.Hidden)
{
node = new TreeNode(list.Title, null, null, list.DefaultViewUrl, “_self”);
parentNode.ChildNodes.Add(node);
}
}
foreach (SPWeb childWeb in thisWeb.Webs)
{
//Call our own helper function for adding each child Web to the tree.
addWebs(childWeb, parentNode);
childWeb.Dispose();
}
siteStructure.CollapseAll();
}

void addWebs(SPWeb web, TreeNode parentNode)
{
TreeNode node;
node = new TreeNode(web.Title, null, null, web.Url, “_self”);
parentNode.ChildNodes.Add(node);
parentNode = node;
foreach (SPList list in web.Lists)
{
if (!list.Hidden)
{
node = new TreeNode(list.Title, null, null, list.DefaultViewUrl, “_self”);
parentNode.ChildNodes.Add(node);
}
}
foreach (SPWeb childWeb in web.Webs)
{
//Call the addWebs() function from itself (i.e. recursively)
//to add all child Webs until there are no more to add.
addWebs(childWeb, parentNode);
childWeb.Dispose();

}
}

}
}

Categories: Uncategorized

SharePoint 2010 Search

Categories: Uncategorized

SharePoint 2010 Excel Service Using REST

Categories: Uncategorized

SharePoint 101 Samples

Categories: Uncategorized

The password supplied with the AD\Administrator was not correct. verify that it was entered correctly and try again.


Error Message:
The password supplied with the AD\Administrator was not correct. verify that it was entered correctly and try again.
Solution:
Open SharePoint 2010 Management Power Shell and give the below command.
Set-SPManagedAccount -UseExistingPassword –Identity Ad\Administrator (Domain\Username) press enter.
Cmdlet Set-SPManagedAccount at command pipeline position 1
Supply values for the following parameters:
ExistingPassword: ********(Specify the password)
Here it asks for confirmation as
Are you sure you wantto perform ths action?
Performing operation “Set-SPManagedAccount” on Target “AD\Administrator”.
[Y] Yes [A] yes to all [n] No [l] no to all [s] suspend
:Specify as “y”
Next give the below command
Repair-SPManagedAccountDeployment
Next “resetiis “

Categories: Uncategorized

Some Facts about Microwave


It has been known for some years that the problem with microwaved anything is not the radiation people used to worry about, it’s how it corrupts the DNA in the food so the body can not recognize it.
Microwaves don’t work different ways on different substances. Whatever you put into the microwave suffers the same destructive process. Microwaves agitate the molecules to move faster and faster. This movement causes friction which denatures the original make-up of the substance. It results in destroyed vitamins, minerals, proteins and generates the new stuff called radiolytic compounds, things that are not found in nature.
So the body wraps it in fat cells to protect itself from the dead food or it eliminates it fast. Think of all the Mothers heating up milk in these ‘Safe’ appliances. What about the nurse in Canada that warmed up blood for a transfusion patient and accidentally killed him when the blood went in dead. But the makers say it’s safe. But proof is in the pictures of living plants dying!!!

Ten Reasons todispose off your Microwave Oven :

From the conclusions of the Swiss, Russian and German scientific clinical studies, we can no longer ignore the microwave oven sitting in our kitchens. Based on this research,one can conclude this article with the following:

1). Continually eating food processed from a microwave oven causes long term – permanent – brain damage by ‘shorting out’ electrical impulses in the brain [de-polarizing or de-magnetizing the brain tissue].

2). The human body cannot metabolize [break down] the unknown by-products created in microwaved food.

3). Male and female hormone production is shut down and/or altered by continually eating microwaved foods.

4). The effects of microwaved food by-products are residual [long term, permanent] within the human body.

5). Minerals, vitamins, and nutrients of all microwaved food is reduced or altered so that the human body gets little or no benefit, or the human body absorbs altered compounds that cannot be broken down.

6). The minerals in vegetables are altered into cancerous free radicals when cooked in microwave ovens.

7). Microwaved foods cause stomach and intestinal cancerous growths [tumours]. This may explain the rapidly increased rate of colon cancer in UK andAmerica .

8). The prolonged eating of microwaved foods causes cancerous cells to increase in human blood.

9). Continual ingestion of microwaved food causes immune system deficiencies through lymph gland and blood serum alterations.

10). Eating microwaved food causes loss of memory, concentration, emotional instability, and a decrease of intelligence

Categories: Good Tags:

SharePoint 2010 Web Part properties


Create a Blank Sharepoint SOlution and named it: MyWebPartProject1 and select farm installation, Select any web site
Add new item to solution and select Visual Webpart.
Named it :MyWebPart1

you have to change below files

MyWebPart1UserControl.ascx
MyWebPart1UserControl.ascx.cs
MyWebPart1.cs

Step 1
——
User control path in sharepoint

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

Open MyWebPart1UserControl.ascx

add to lables and named it: lbl_MySelection,ddl_MySelection

Step 2
——–
Open MyWebPart1.cs

Add below COde.

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace MyWebPartProject1.MyWebPart1
{
[ToolboxItemAttribute(false)]
public class MyWebPart1 : WebPart
{
[WebBrowsable(true),
Category(“Miscellaneous”),
Personalizable(PersonalizationScope.Shared),
WebDisplayName(“Enter Your Name”)]
public string CustomTextProp { get; set; }

public enum ddlEnum { India, US, UK }
[WebBrowsable(true),
Category(“Miscellaneous”),
Personalizable(PersonalizationScope.Shared),
WebDisplayName(“Select Your Country”)]
public ddlEnum ddlProp { get; set; }

// Visual Studio might automatically update this path when you change the Visual Web Part project item.
private const string _ascxPath = @”~/_CONTROLTEMPLATES/MyWebPartProject1/MyWebPart1/MyWebPart1UserControl.ascx”;

public string _OptionValue { get; set; }

protected override void CreateChildControls()
{
MyWebPart1UserControl control = Page.LoadControl(_ascxPath) as MyWebPart1UserControl;
if (control != null)
control.WebPart = this;
Controls.Add(control);

}
}

}

Step 3
———-
Open MyWebPart1UserControl.ascx.cs

Add below Code

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace MyWebPartProject1.MyWebPart1
{
public partial class MyWebPart1UserControl : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public MyWebPart1 WebPart { get; set; }

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
if (this.WebPart != null && this.WebPart.CustomTextProp != null)
{
lbl_MySelection.Text = this.WebPart.CustomTextProp.ToString();
ddl_MySelection.Text = this.WebPart.ddlProp.ToString();
}
}
}
}
———————-
Below code other feature editwebpart
==========================================================
Editwebpart
———-

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace MyWebPartProject1.MyWebPart
{
[ToolboxItemAttribute(false)]
public class MyWebPart : WebPart
{
// Visual Studio might automatically update this path when you change the Visual Web Part project item.
private const string _ascxPath = @”~/_CONTROLTEMPLATES/MyWebPartProject1/MyWebPart/MyWebPartUserControl.ascx”;
public string _OptionValue { get; set; }

public enum ddlEnum { option1, option2, option3 }
[WebBrowsable(true),
Category(“Miscellaneous”),
Personalizable(PersonalizationScope.Shared),
WebDisplayName(“Dropdown List Display Text”)]
public ddlEnum ddlProp { get; set; }

//[WebBrowsable(true),
//Category(“Miscellaneous”),
//Personalizable(PersonalizationScope.Shared),
//WebDisplayName(“Enter some text”)]
//public string CustomTextProp { get; set; }

protected override void CreateChildControls()
{
MyWebPartUserControl control = Page.LoadControl(_ascxPath) as MyWebPartUserControl;
if (control != null)
control.WebPart = this;
Controls.Add(control);
}
}
public class MyEditorPart : EditorPart
{
private Label lbl_Options;
private DropDownList ddl_Options;

protected override void CreateChildControls()
{
base.CreateChildControls();
ddl_Options = new DropDownList();
lbl_Options = new Label();
lbl_Options.Text = “Choose:
:”;
using (SPSite site = new SPSite(“http://” + Page.Request.Url.Host.ToString()))
{
using (SPWeb web = site.OpenWeb())
{
SPList Forms = web.Lists[“News”];
SPQuery qry = new SPQuery();
qry.Query = @”0″;
SPListItemCollection SPLIC = Forms.GetItems(qry);
if (SPLIC != null && SPLIC.Count > 0)
{
foreach (SPListItem SPLI in SPLIC)
{
string OptionTitle = “”;
string OptionID = “”;
if (SPLI[“ID”] != null)
OptionID = SPLI[“ID”].ToString();
if (SPLI[“Title”] != null)
OptionTitle = SPLI[“Title”].ToString();
if (OptionTitle != “” && OptionID != “”)
ddl_Options.Items.Add(new ListItem(OptionTitle, OptionID));
}
}
}
}
Controls.Add(lbl_Options);
Controls.Add(ddl_Options);
}

public override bool ApplyChanges()
{
EnsureChildControls();
MyWebPart webPart = WebPartToEdit as MyWebPart;

if (webPart != null)
webPart._OptionValue = ddl_Options.SelectedValue.ToString();
return true;
}

public override void SyncChanges()
{
EnsureChildControls();
MyWebPart webPart = WebPartToEdit as MyWebPart;

if (webPart != null)
{
ddl_Options.SelectedValue = webPart._OptionValue.ToString();
}
}
}
}

Ref:http://blog.concurrency.com/sharepoint/create-a-custom-web-part-for-sharepoint-2010/

Bulk Insert in to sql table


/* Inserting data into Source table for testing*/

DECLARE @MaxVal INt ,@Inc INT,@DateInc Int
SET @MaxVal = 450000
SET @Inc = 1
SET @DateInc =1

WHILE(@Inc 90000)
SET @DateInc = 1

END

SharePoint 2010 PowerShell

Count Semicolon Values in Excel


Source: A;b;c;d

Open Excel

Paste in the Excel selected data.

Select Data which you have pasted

Click Data TabàClick Test to Columns

You will get new window.

Click Next

Uncheck TAB, check Semicolon

Semicolon will remove from your data.

Copy the data.

Select any cell

Right click

Click Paste Special

New window will open

Check Transpose

Your data will come vertical lines.

Now you count your values.