Pages

Thursday, August 27, 2015

Cannot connect to the server at this time. Your table cannot be published. - SOLVED

Problem:

While importing data from excel file to SharePoint, user may get below error.


Solution:

This is a issue with permissions a user is having. 

For e.g. if user is having "Contribute" access permission then with “Contribute” access permission level, we don’t have an access to create a list in a site. When we import from excel to SharePoint, SharePoint will create a list and as we do not have a permission to create a list, that’s why user may get this error.

Solution is to elevate your permissions.

Read More »

Wednesday, June 10, 2015

How to display Previous and Next buttons or icons in JQuery Datepicker

Folks,

You must have noticed sometimes while using JQuery datepicker control (which comes from jquery-ui.css file) we get the datepicker control but it doesn't display "Previous" and "Next" buttons or icons as shown below.



The fix is to apply a CSS and display them by using below code.


<style type="text/css">
        .ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span {
            background-image: url("https://your_url_of_the_site/folder_where_images_are_uploaded/ui-icons_ef8c08_256x240.png");
        }
 </style>


Above, you can see I am using a code which apply CSS to your ".aspx" or ".ascx" or ".html" page where you are using this datepicker control.

NoteThe URL I am pointing is to the place where your images are stored. These images are those which comes along with when you download the "jquery-ui" library. In this example, I have stored them in a SharePoint library and I am referencing to them there.

Result comes as shown below after applying the CSS:


Hope this helps!
Read More »

Thursday, May 28, 2015

How to get QueryString from URL using JQuery

QueryString using JQuery

There are lots of ways to get query-string from the web URL by using jQuery but this is the best way I feel to retrieve one or more than one query-strings parameters from the URL.

How to do it?

Let's suppose your URL is http://YourUrl.aspx.

It has 2 query-string parameters i.e. "itemid" and "status".

The parameter "itemid" has value as "1" and parameter "status" has value as "Approve".

So, now your URL will be http://YourUrl.aspx?itemid=1&status=Approve.

In your (document).ready() function, add the code as shown below for the URL which has two query-string parameters (i.e. http://YourUrl.aspx?itemid=1&status=Approve):

  $(document).ready(function () {
            var queryString = new Array();
            if (queryString.length == 0) {
                if (window.location.search.split('?').length > 1) {
                    var params = window.location.search.split('?')[1].split('&');
                    for (var i = 0; i < params.lengthi++) {
                        var key = params[i].split('=')[0];
                        var value = decodeURIComponent(params[i].split('=')[1]);
                        queryString[key] = value;
                    }
                }
            }

            if (queryString["itemid"] != null && queryString["status"] != null) {
                try {
                    alert("Your Item ID is: " + queryString["itemid"] + ", Your Status is:" queryString["status"]);
                }
                catch (e) { }
            }
        });

As you can see that using array variable, we can store more than one query-string parameters and retrieve them by passing their key.

I hope this helps!!

Read More »

Thursday, March 12, 2015

How to order fields in SharePoint custom list's NewForm.aspx page

Ordering fields in SharePoint custom list’s NewForm.aspx page


We have seen that lots of time we need to change the order in which some fields appear on the new list item form (i.e. NewForm.aspx) for any of the SharePoint custom lists. Regardless of the ordering in the view you have selected or created, the fields always seem to appear in the order they were created while creating a custom list on the new item form.

So question comes, how to reorder them?

Well, one way is to create altogether a new form using SharePoint designer and then reorder the column as it will have data view web part.

The other solution which doesn't require SharePoint designer is through content type. To order the columns without using SharePoint designer or creating a new form, follow below steps:

-    Go to the list

-    Go to list settings (from the ribbon in 2013 and 2010, from the drop downs in 2007)

-    Click Advanced settings

-    Ensure ‘allow management of content types’ is checked

-    Go back to the list settings

-    In the list of content types associated with the list, click the one you want to change the order of fields for (in lists that have been created ad hoc this is usually item or document).

-    In the bottom of the screen a link appears called ‘Column order’

-    Click on 'Column order' and then you can order your fields accordingly

-    Once done, click 'OK' button and now create new item and you will see your fields are ordered accordingly
Read More »

Tuesday, January 27, 2015

How to redirect from one page to another in SharePoint Sandbox solutions (especially when they are deployed to SharePoint Online)



How to redirect from one page to another in SharePoint Sandbox solutions (especially when they are deployed to SharePoint Online)?



Answer -


There are lots of ways to achieve this but the following one works almost everywhere for the sandbox solutions.

On a button click event (or accordingly) of your ".cs" file, just add following code:


string pageURL = "www.yourpageurl.com";
var jscript = "<script type='text/javascript'
language='javascript'>window.location='"
+ pageURL + "';</script>";
var literal = new Literal();
literal.Text = jscript;
this.Controls.Add(literal);


The above code will add "Literal" control to page with the specified URL and the page will be redirected to the URL specified.

What is Literal Control?

- The Literal Control is similar to the Label Control as they both are used to display static text on a web page.
- The Literal Control is not inherited from WebControl namespace.
- The Literal Control doesn't provide substantial functionality but Literal text is programmable.
- It doesn't add any HTML elements to the web page. This control makes it possible to add HTML code directly in the code designer window without switching to design view and clicking the HTML button to edit the HTML.
- We cannot apply a style to a literal control.
- Unlike Label control, there is no property like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc. for Literal control.

That makes it more powerful, we can even put a pure HTML contents into it.

When to use Literal Control?
- Literal control is one of the rarely used controls but it is very useful.
Literal control is light weight control.
- The Literal Control is useful when we want to add text to the output of the page dynamically (from the server).
- With that we can even programmatically manipulate the Literal text from the code behind.

In short we can say:

The Literal control is used to display text; that is, it renders static text on a Web page without adding additional HTML tags. It passes content directly to the client browser unless we use the Mode property to encode the content.
 

Read More »

Thursday, January 22, 2015

Change 'Title' Column Display Name Using List Definition In SharePoint

Question: How to change "Title" column display name in default view of a list when creating list by list definition using Visual Studio in SharePoint?

Answer: In Schema.xml file of your list definition project, search for "Fields" tag (i.e. <Fields>) and just before the closing tag of this "Fields" tag (i.e. </Fields> ), put below line of code (also see attached image):

<Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="LinkTitle" DisplayName="First Name" />

In the above line of code:
ID = ID of your "Title" field
Type = Same as of your "Title" field i.e "Text"
Name = LinkTitle (it will refer to the "Title" text in default view)
DisplayName = The name you want to display in your default view instead of "Title"

Hope this helps!



Read More »

Wednesday, January 7, 2015

Cannot Connect To The SharePoint Site

Cannot Connect To The SharePoint Site

While creating a SharePoint solution in Visual Studio, if you get an error shown in a screenshot below when you validate your SharePoint site URL, just provide user with a "DB_Owner" access to the "WSS_Content", "WSS_Logging" and "SharePoint_Config" database. This will resolve the issue.




Read More »

Tuesday, September 30, 2014

How to change a Title of a wiki page in SharePoint 2013 without affecting its page name and page URL

How to change a Title of a wiki page in SharePoint 2013 without affecting its page name and page URL

Please also see my new post on - Easy Way To Change Wiki Page Title In SharePoint 2013 .

In a SharePoint wiki page, if we would like to change the “Title” of a page, we would have to change the “Page Name” itself. This becomes very irritating because if we want our page title to be named as for example “My Page Title”, this will also rename the page name.

Questions comes how to get rid of it.

There are 2 ways. Both requires some coding.

    1. Using SharePoint Designer 2013 and modifying "EnterpriseWiki.aspx"
    2. Using JQuery script, in case EnterpriseWiki.aspx is not available
  1. Let’s see how we can change the page title of our wiki page using SharePoint designer:

This solution involves two small code changes and a new Authoring habit.

  • Open the site in SharePoint Designer 2013, and open this: /_catalogs/masterpage/EnterpriseWiki.aspx
Note: It is a good idea to make a copy of this file somewhere.
  • Find the content place holders with IDs PlaceHolderPageTitle and PlaceHolderPageTitleInTitleArea.
  • Edit the SharePoint:ListItemProperty  for both content place holders by adding a new property called Property with the value of Title.


  • Next, find the SharePoint:FileField control with ID PageNameInEditMode
  • Add the following code just below that line:








It should look like this:

  • Save and close.
Now the page will display the Title property instead of the Name (i.e., file name). The edit form will show both the Name and the Title (similar to list view edit forms). You can test it by changing the Name of a page and then looking at the displayed Title and tab Title compared to the URL. 

  2.  If you don’t see “EnterpriseWiki.aspx” page, don’t worry, we can add JQuery script to our Wiki page to change the title. Let’s see how this can be done with JQuery:

  • Open your Wiki page and click on “Edit Page”
  • Add script editor web part and in script editor web part, just add below script:

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#DeltaPlaceHolderPageTitleInTitleArea > span > span > a").text("My Page Title");
    });
</script>

  • Save and Close the Edit mode of the page and you will see the title as changed
Hope this will help many of you.

Read More »

Friday, May 30, 2014

Could not find this item in Windows 7


Recently, I was trying to delete a file in my laptop (has Windows 7) which threw an error as "Could not find this item" and was not deleting that file at all.

After searching for sometime, I finally found a solution which helped me in deleting the file.

Here is the solution:

1) Open a Command Prompt.
2) Browse to the folder containing the buggy file.
3) Type 'dir /x' to obtain the 8.3 formatted filename.
4) Delete the file using the 8.3 filename, e.g. 'del 0WELCO~1' (as shown below)

Hope this information may help you and others with the same problem.





Read More »

Thursday, April 24, 2014

Open CSV file instead of saving in SharePoint 2013

Usually when we save any CSV file in SharePoint document library and we open it, the browser actually prompts to "Save" the file first and then gives "Open" file option.

How to make some settings so that browser allows CSV files to get "Open" instantly without saving them?

Here is the solution -

In your SharePoint 2013 server, make the settings in “IIS Mime Types” and in “DOCICON” file to open the CSV files from the browser instead of saving them.
Steps to follow are:
a.       Add an entry to DOCICON.XML -
This file is located by default at: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\XML\. Open the file DOCICON.XML for editing and add the following line in the ByExtension element:

b.      Change the MIME type associated with the CSV Extension in Internet Information Server (IIS)
To do this:
                                                               i.      Run the “Internet Information Services (IIS) Manager” application from the Start/Administrative tools menu.
                                                             ii.      Select the server in the left-hand pane.
                                                            iii.      Select “MIME Types” in the list of options in the middle pane.
                                                           iv.      Then locate the .CSV entry (it should already exist) and change the MIME type to: application/vnd.ms-excel, and click OK.


Finally, most importantly, reset the IIS by clicking on Start -> Run -> cmd -> Type "IISReset"


For more reference, check these posts as well:



Read More »

Wednesday, April 16, 2014

Implementing Autocomplete Textbox in SharePoint

Implementing Autocomplete TextBox in SharePoint

In my recent project activity, I got a requirement to fill the textbox with autocomplete functionality. After some research and struggle, I was able to achieve it.

The best thing about the solution I created is, it is cross browser compatible. I have tested it in Chrome and Internet Explorer.

What is autocomplete?

Autocomplete means when user starts typing the characters in a textbox, just below the textbox, user sees the suggestions. The best example is google search textbox. When you enter any text in the google search textbox, it starts showing you the suggestions of a thing you are looking for.

How to achieve it in SharePoint Visual Web Part?

To achieve it, you should use JQuery and SPServices in your SharePoint solution.



The way to achieve it via JQuery and SPServices is:

Let’s say you have created a Visual Web Part in SharePoint and you have a textbox in your web part which you want to make as an autocomplete textbox. Now, this textbox should show the suggestions coming from your custom list named as “Items” and the column which it should target in your custom list is “ItemNumber”.
Just put below lines of code in your Visual Web Part’s “ascx” file, change the list name and the column name as per your need and you will be good to go:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.1a/jquery.SPServices-0.7.1a.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var itemSource = [];
        var k = 0;
        $().SPServices({
            operation: "GetListItems",
            async: false,
            listName: "Items",
            CAMLViewFields: '',
            CAMLQuery: '',
            completefunc: function (xData, Status) {
                $(xData.responseXML).SPFilterNode("z:row").each(function () {
                    itemSource[k] = $(this).attr('ows_ItemNumber');
                    k = k + 1;
                });

                $('#<%=txtAutoComplete.ClientID%>').autocomplete({
                    source: itemSource,
                    minLength: 0
                });

            }
        });

    });


</script>
<asp:TextBox ID="txtAutoComplete" runat="server"></asp:TextBox>

So what we have done here is:

Have given reference to the:
͐   JQuery UI js file
͐   JQuery js file
͐   Autocomplete js file
͐   SPServices js file

Have used JQuery variable as “itemSource” as an array to store the column values we will get from the custom list

Have used JQuery variable as “k” to keep the track of current item index

Under “SPService” function have used:

͐   Operation as “GetListItems” as we want list items from the list
͐   Kept async as false
͐   Used listName as “Items” and column name as “ItemNumber”
͐   Defined CAMLViewFields and CAMLQuery

Once the parameters provided above matches and gets validated, the “completeFunc” will be executed which will:
͐   Go through the “z:row” as it will hold the values returned by the SPService
͐   Add the provided column name to the array
͐   Index value will be increased by 1

Once “completeFunc” gets executed, the textbox will be used to bind the data to its datasource which we have in an array i.e. “itemSource”


Hope this helps!
Read More »

Monday, February 10, 2014

How to Hide RadEditor Toolbar


How to Hide RadEditor Toolbar 

Requirement
No doubt that “Telerik” controls are very useful and they have so much to offer but sometimes there are few things which “Telerik” doesn’t provide to meet our requirement purpose. Hiding “RadEditor” control toolbar is one of them. “RadEditor” control doesn’t comes with any property to hide its toolbar.

Solution
So what’s the solution to hide “RadEditor” control toolbar? Solution is to hide it through a "CSS" class.

How?
On your page where you are using “RadEditor” contorl or in a “CSS” file which you are referring in your page, you can put below line of code to hide it:
<style type="text/css">
    .reToolbarWrapper
    {
        display: none;
    }
</style>

 
That should do it!!







Read More »