Friday, February 7, 2014

Check if Site exits using Client Object Model SharePoint

public bool CheckifSiteExits(string Siteurl)
        {
            bool Exits = true;
            try
            {
                ClientContext context = new ClientContext(Siteurl);
                context.Credentials = new System.Net.NetworkCredential("doula", "zoo.why.ace-709", "asiapacific");
                Site mySite = context.Site;
                context.Load(mySite);
                context.ExecuteQuery();
                context.Dispose();
            }
            catch (Exception checkEx)
            {
                string chckErr = checkEx.Message;

                Exits = false;
            }
            return Exits;
        }


 Boolean siteCheck = CheckifSiteExits("http://localhost:1188/sites/234234234234");

            if (siteCheck)
            {
                //output site existed message
            }
            else
            {
                //create site using COM
            }

20 comments:

  1. http://bilbrobloggins.com/sharepoint/dropdown-list-box-filter-web-part-in-sharepoint-ndash-part-two/

    ReplyDelete
  2. public class DropdownFilterWP : WebPart, ITransformableFilterValues
    {
    private DropDownList _sourceDropDownList = null;
    protected override void CreateChildControls()
    {
    _sourceDropDownList = new DropDownList();

    _sourceDropDownList.AutoPostBack = true;

    this.Controls.Add(_sourceDropDownList);

    }
    protected override void OnInit(EventArgs e)
    {
    base.OnInit(e);
    EnsureChildControls();

    }
    private SPList _sourceList = null;
    private string _sourceListName = null;
    private string _displayTextField = null;
    private string _valueField = null;

    private SPList SourceList
    {
    get
    {
    if ((_sourceList == null) && (this.SourceListName != null))
    {
    try
    {
    _sourceList = SPContext.Current.Web.Lists[SourceListName];
    }
    catch
    {
    // TODO: Insert your custom error handling here
    }
    }
    return _sourceList;
    }

    }

    ReplyDelete
  3. [WebBrowsable(true),

    Personalizable(PersonalizationScope.User),

    WebDescription("Source List Name"),

    Category("Dropdown Filter"),

    WebDisplayName("List Name")]

    public string SourceListName
    {

    get { return _sourceListName; }

    set { _sourceListName = value; }

    }


    [WebBrowsable(true),

    Personalizable(PersonalizationScope.User),

    WebDescription("Display Text Field"),

    Category("Dropdown Filter"),

    WebDisplayName("Display Text Field")]

    public string DisplayTextField
    {

    get { return _displayTextField; }

    set { _displayTextField = value; }

    }

    [WebBrowsable(true),

    Personalizable(PersonalizationScope.User),

    WebDescription("Value Field"),

    Category("Dropdown Filter"),

    WebDisplayName("Value Field")]

    public string ValueField
    {
    get
    {
    string returnValue = String.Empty;
    if ((_valueField != null) && (_valueField.Length > 0))
    {
    returnValue = _valueField;
    }
    else
    {
    if (this.SourceList != null)
    {
    DataTable dataTable = this.SourceList.Items.GetDataTable();
    if ((dataTable != null) && (dataTable.Columns.Count > 0))
    {
    returnValue = dataTable.Columns[0].ColumnName;
    }
    }
    }
    return returnValue;
    }
    set { _valueField = value; }
    }

    protected override void OnLoad(EventArgs e)
    {
    base.OnLoad(e);
    LoadData();
    }

    ReplyDelete
  4. private void LoadData()
    {
    if (this.Page.IsPostBack == false)
    {
    if ((SourceList != null) && (SourceList.Items != null))
    {
    for (int i = 0; i < SourceList.Items.Count; i++)
    {
    SPListItem item = SourceList.Items[i];
    ListItem listItem = new ListItem();
    if (this.DisplayTextField != null && this.DisplayTextField.Length > 0)
    {
    listItem.Text = item[this.DisplayTextField].ToString();
    }
    else
    {
    listItem.Text = item[0].ToString();
    }
    if (this.ValueField != null && this.ValueField.Length > 0)
    {
    listItem.Value = item[this.ValueField].ToString();
    }
    else
    {
    listItem.Value = item[0].ToString();
    }
    _sourceDropDownList.Items.Add(listItem);
    }
    }
    }
    }

    public System.Collections.ObjectModel.ReadOnlyCollection ParameterValues
    {
    get
    {
    string selectedValue = String.Empty;
    if ((_sourceDropDownList != null) && (_sourceDropDownList.SelectedItem != null))
    {
    selectedValue = _sourceDropDownList.SelectedItem.Value;
    }

    string[] values = new string[] { selectedValue };

    return new ReadOnlyCollection(values);

    }

    }
    }

    interface ITransformableFilterValues
    {
    public bool AllowAllValue
    {
    get { return false; }
    }

    public bool AllowEmptyValue
    {
    get { return true; }
    }

    public bool AllowMultipleValues
    {
    get { return false; }
    }

    public string ParameterName
    {
    //get
    //{
    // if ((this.ValueField != null) && (this.ValueField.Length > 0))
    // {
    // return this.ValueField;
    // }
    // else
    // {
    // return "Unknown";
    // }
    //}
    }
    }

    ReplyDelete
  5. http://msdn.microsoft.com/en-us/library/bb457205(v=office.12).aspx

    ReplyDelete
  6. http://ukreddysharepoint2010.blogspot.in/2012/07/how-to-create-page-layout-in-sharepoint.html

    ReplyDelete
  7. http://www.sharepointpals.com/post/How-to-Create-a-Page-Layout-(PageLayout)-with-ContentType-in-SharePoint-2013

    ReplyDelete
  8. http://blogs.technet.com/b/tothesharepoint/archive/2013/11/11/how-to-add-refiners-to-your-search-results-page-for-sharepoint-2013.aspx

    ReplyDelete
  9. http://blogs.technet.com/b/sharepoint_made_easy/archive/2013/03/19/step-by-step-configuration-to-add-custom-refiners-in-the-refinement-panel-of-search-results-page-for-sharepoint-online.aspx

    ReplyDelete
  10. http://www.brainlitter.com/2013/03/22/sharepoint-2013-search-scopes-are-gone-but-dont-fret/

    ReplyDelete
  11. http://technet.microsoft.com/en-us/library/dn186229(v=office.15).aspx

    ReplyDelete
  12. http://technet.microsoft.com/en-in/library/jj683115(v=office.15).aspx

    ReplyDelete
  13. http://gavinb.net/2014/04/14/sharepoint-2013-search-add-user-profile-properties-to-the-full-text-index/

    ReplyDelete
  14. http://blog.helloitsliam.com/Lists/Posts/Post.aspx?ID=119

    ReplyDelete
  15. http://ybbest.wordpress.com/2012/03/17/how-to-add-event-receiver-to-sharepoint2010-content-type-programmatically/

    ReplyDelete
  16. http://www.arnoldboersma.nl/

    Enable anonymous access to SharePoint 2013 – Part 1- Configure Web Application and SiteCollection

    ReplyDelete
  17. http://sharepointjack.com/2013/a-simple-powershell-script-for-redeploying-a-sharepoint-wsp-solution-file/

    ReplyDelete
  18. http://blog.pixelmill.com/1123/housekeeping-deactivation-removing-what-you-added/

    ReplyDelete
  19. https://www.youtube.com/watch?v=rje25vBQEDA

    ReplyDelete
  20. http://social.technet.microsoft.com/wiki/contents/articles/1262.test-lab-guides.aspx

    ReplyDelete