Archive

Archive for October, 2011

SharePoint Site Definitions


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

 

Advertisements
Categories: Uncategorized

Sharepoint Webpart 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
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 = “<strong>Choose:</strong><br />:”;
            using (SPSite site = new SPSite(“http://&#8221; + 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 &amp;&amp; SPLIC.Count &gt; 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 != “” &amp;&amp; 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();
            }
        }
    }
}

 

Categories: Uncategorized

Sharepoint User control path


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

 

Categories: Uncategorized

Trim String Array


protected void Page_Load(object sender, EventArgs e)
{
string strArray = “a3 ,r8,t4,a3,y7 ,a3 “;
string[] stringArray = strArray.Split(‘,’);
stringArray = TrimArray(stringArray);
 
}
private string[] TrimArray(string[] stringArray)
{
for (int i = 0; i < stringArray.Length; i++)
{
stringArray[i] = stringArray[i].Trim();
}
 
return stringArray;
}

 

Categories: Uncategorized

user profile created automatically in windows


Solution: We can limit the mo of User Account so that system will not create new profiles.

Configuring Windows 7 for a Limited User Account
http://www.unixwiz.net/techtips/win7-limited-user.html

Categories: Uncategorized

Enable the Lock Pages in Memory Option IN WINDOWS


On the Start menu, click Run. In the Open box, type gpedit.msc.
 
The Group Policy dialog box opens.
 
On the Group Policy console, expand Computer Configuration, and then expand Windows Settings.
 
Expand Security Settings, and then expand Local Policies.
 
Select the User Rights Assignment folder.
 
The policies will be displayed in the details pane.
 
In the pane, double-click Lock pages in memory.
 
In the Local Security Policy Setting dialog box, click Add.
 
In the Select Users or Groups dialog box, add an account with privileges to run sqlservr.exe.

 

Categories: Uncategorized

How to convert xml doc to word using XSLT


How to convert xml doc to word using XSLT

Categories: Uncategorized