Tuesday, September 30, 2014

"The file that you selected could not be found. Check the spelling of the file name and verify that the location is correct" when calling ExceService.OpenWorkbook in sharepoint with non adiministrator priveleges

Few days ago ,I have the same probelm with you ,and later I have figured it out,the Solution as follows:
The problem you must configure alternate access mappings which in  System Settings of SharePoint 2010 Central Administration.
you should select you local application,such as Http://sharepoint:22222, and Edit Public URLs ,in the internet box you fill your internet url ,then
click ok,and test, I think you will find it's OK.

Wednesday, September 17, 2014

Sharepoint Redirecting from 1 page to another

string url = "~remoteAppUrl/Pages/PollQuestionView.aspx";

string queryString = "SPHostUrl=http%3a%2f%2fspmain%3a3865&SPLanguage=en??-US&SPClientTag=0&SPProductNumber=15.0.4420.1017";

SPUtility.Redirect(url, SPRedirectFlags.Default, Context, queryString);

Tuesday, September 16, 2014

Get Modal Popup sharepoint 2010


  • Create a share point visual web part project and add below to the ascx page 
  • Create A Parent page and child page
Parent Page---> where web part is deployed
Child Page -- >  which you want to see in popup



protected void Page_Load(object sender, EventArgs e)
        {
            ShowBasicDialog(appSettings, "Announcements");
        }


        private void ShowBasicDialog(string Url, string Title)
        {
            //string heignt = "400";
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(@"<script type=""text/ecmascript"" language=""ecmascript"">");
            sb.AppendLine(@"ExecuteOrDelayUntilScriptLoaded(openBasicServerDialog, ""sp.js"");");
            sb.AppendLine(@"    function openBasicServerDialog()");
            sb.AppendLine(@"    {");
            sb.AppendLine(@"        var options = {");
            sb.AppendLine(string.Format(@"            url: '{0}',", Url));
            sb.AppendLine(string.Format(@"            title: '{0}',", Title));
            sb.AppendLine(string.Format(@"            height: '{0}',", "550"));
            sb.AppendLine(string.Format(@"            width: '{0}'", "550"));
            sb.AppendLine(@"        };");
            sb.AppendLine(@"        SP.UI.ModalDialog.showModalDialog(options);");
            sb.AppendLine(@"    }");
            sb.AppendLine(@"</script>");
            ltScriptLoader.Text = sb.ToString();

            //<br>iframe<br>{<br>    background-image: url("../images/animatedspinner.gif");
        }
    }



add below key to app settings in web.config
  <add key="SPUrl" value="http://localhost:99/SitePages/Home.aspx" />

Sharepoint Get image URL and Details from sharepoint Picture Library

 public void dispImgItems()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite mySiteCollection = new SPSite(appSettings))
                {
                    using (SPWeb web = mySiteCollection.OpenWeb())
                    {
                        SPList LstPicture = web.Lists["AnnPictureLibrary"];
                        List<ImageCollection> lsts = new List<ImageCollection>();
                        foreach (SPListItem item in LstPicture.Items)
                        {
                            if (item["Active"].ToString() == "Yes")
                            {
                                string ImageUrl = Convert.ToString(item["ows_EncodedAbsUrl"]);
                                string ImageName = Convert.ToString(item["Title"]);
                                lsts.Add(new ImageCollection(ImageUrl, ImageName));

                            }
                        }
                        //Image1.=
                        Image1.AlternateText = lsts[0].Name;
                        Image1.ImageUrl = lsts[0].URL;
                        Image1.Height = 400;
                        Image1.Width = 400;
                    }
                }
            });
        }
    }