Tuesday, December 16, 2014
What is Web part life Cycle in SharePoint 2013 and SharePoint 2010
Posted by
Santhosh,
on
11:55 PM
Hi Friends,
Thanks for visiting my blog .
In this post , i would like to describe the web part life cycle events in SharePoint 2013.
Like Asp.Net life cycle there is also Web Part life cycle. So it is better to understand the web part life cycle.
OnInit:
This method handles initialization of the control.
OnLoad:
This event handles the Load event. This is also used for initialize the control but is not intended for loading data or other processing functionality.
CreateChildControls:
This is the most popular event in web part life cycle. This creates any child controls. So if you are adding any control to display then you have to write in this method.
EnsureChildControls:
This method ensures that CreateChildControls has executed. EnsureChildControls method must be called to prevent null reference exceptions.
SaveViewState:
View state of the web part saved.
OnPreRender:
This method handles or initiates tasks such as data loading that must complete before the control can render.
Page.PreRenderComplete:
The page fires the PreRenderComplete event after all controls have completed their OnPreRender methods.
Render:
This method is used to render everything.
RenderContents:
Renders the contents of the control only, inside of the outer tags and style properties.
OnUnload:
Performs the final cleanup.
Hope this post will help you......
How to Hide Controls in SharePoint New Form Based on User using ECMA Script.
Posted by
Santhosh,
on
2:13 AM
Hi Guys,
Thanks for visiting our blog.
In Share Point we have If condition "If this user is member of this share point group" We can use this condition to check any user belongs to particular group or not.
Scenario:
Check user belongs to a SharePoint Group and Hide some controls in New/Edit Forms on SharePoint Custom List.
Solution:
The
following Script which will help you in checking if the current logged
in SharePoint user belongs to a SharePoint user group and based on it
hide some controls in New/Edit forms on Custom List.
Step 1: Navigate to your SharePoint 2013 site.
Step 2: From this page select Site Actions | Edit Page:
Edit
the page, go to the "Insert" tab in the Ribbon and click the "Web Part"
option. In the "Web Parts" picker area, go to the "Media and Content"
category, select the "Script Editor" Web Part and press the "Add
button".
Step 3: Once the Web Part is
inserted into the page, you will see an "EDIT SNIPPET" link; click it.
You can insert the HTML and/or JavaScript as in the following:
Script
<script src="/sites/JohnHancock/JS/jquery-1.4.2.min.js"></script><script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(disableControls,
"sp.js");
var clientContext = null;
var web = null;
var users ;
var oList;
var oListNew;
function disableControls()
{
clientContext = new
SP.ClientContext();
var groupCollection =
clientContext.get_web().get_siteGroups();
var group = groupCollection.getById(4);//the SharePoint usergroup
users =
group.get_users();
clientContext.load(group);
clientContext.load(users);
currentUser =
clientContext.get_web().get_currentUser();
clientContext.load(currentUser);
clientContext.executeQueryAsync(Function.createDelegate(this,
this.onQuerySucceeded), Function.createDelegate(this,
this.onQueryFailed));
RefreshCommandUI();
}
function onQuerySucceeded()
{
if(this.users.get_count() >0)
{
var UserExistInGroup = false;
for(var i=0; i < users.get_count(); i++)
{
//alert(users.itemAt(i).get_loginName());
//alert(this.currentUser.get_loginName());
if(users.itemAt(i).get_loginName() == this.currentUser.get_loginName())
{
UserExistInGroup
= true;
break;
}
}
}
if (UserExistInGroup)
{
$('nobr:contains("Approver")').closest('tr').show();
}
else
{
$('nobr:contains("Approver")').closest('tr').hide();
}
}
function onQueryFailed(sender, args)
{
}
</script>
This is how we use to hide /unhide the columns in SharePoint Out of box forms.
What is the Content Type for Custom List in SharePoint 2013, SharePoint 2010
Posted by
Santhosh,
on
1:19 AM
Hi Guys,
Thanks for visiting our blog .
Every Custom List is having a content type inherited in it . For Custom Lists in SharePoint the default content type is "item".
If we want to see the content type associated to list .
Go to List Settings
--->Advance Settings(Under General Settings)
---> Allow Content Types
-->Select Yes radio button.
Then you can able to see the content type associated with the list .
If You want to know the content type id just click on the content type (item).
What is calculated column in SharePoint 2013 ,2010
Posted by
Santhosh,
on
12:56 AM
Hi Guys,
Thanks for visiting my blog .
While creating Columns in Custom List many of us have seen the Calculated Column .
I will describe the calculated column for Month and year .
Thanks for visiting my blog .
While creating Columns in Custom List many of us have seen the Calculated Column .
I will describe the calculated column for Month and year .
Go to the list
settings and then click on Create column to add a new column. Give the
column name and chose the column type as calculated column. Then in the
formula write like below:
=TEXT([Created],"yyyy")
he above
formula will return the formula as a single line text, Now if you want
to return as integer then you can write the formula like below:
=YEAR(Created)
Similarly
if you want to store month then follow the above step and write the formula like below:
=Text(Created, "MMMM") : This will return the full month name
=Text(Created, "MMM") : This will return first 3 letters of the month name
=Text(Created, "MM") : This will return integer month
If you want to return the value as an integer then you can write the formula like below:
=MONTH(Created)
Now if you will check the output will come like above :
Monday, December 15, 2014
Difference between SharePoint 2010 List and Document Library
Posted by
Santhosh,
on
5:34 AM
Hi Guys,
Here we have some difference between Lists and Libraries in SharePoint
| Lists | Libraries |
| SharePoint lists are web based editable tables.It gives us the ability to work with structured data. | SharePoint libraries are a list of files. |
| List is going to store the same sorts of data that you would normally place into a spreadsheet. | Library is used to store documents. |
| A list contains items that are collections of fields/properties/columns.optionally can have one or more attachment. | A library is a list ,but have one and exactly one file associated with each item .A library item also has fields/properties/columns. |
| SharePoint list doesnot support check in and check out options. | SharePoint Library supports check in and check out options. |
| When the user searches for a keyword in a document , if the document is in a list then search returns the list item as the result. | When the user searches for a keyword in a document , if the document is in a library then they find the document listed in the search results. |
| Example of SharePoint lists are Contact lists,Task lists etc. | Examples of DocumentLibraries are PictureLibrary,FormLibrary etc. |
What is Look up Column and how to use in SharePoint 2010,2013
Posted by
Santhosh,
on
4:26 AM
Hi Guys,
Thanks for visiting my blog .
Look up Columnin SharePoint 2010 and 2013
When you create a column, you can specify that the column must contain unique values. This means that the list cannot have any duplicate values in that column. You cannot add a list item that contains a duplicate value, modify an existing list item that would result in creating a duplicate value, or restore an item from the Recycle Bin if it would result in a duplicate value. Furthermore, if you create a lookup column in a source list, and you define that column to be unique, the column in the target list must not contain duplicate values.
Note Uniqueness is not case-sensitive, so for example, ORD-231 and ord-231 are considered duplicate values.
A unique column must also have an index. When you create a unique column, you may be prompted to create the index and it is automatically created when you click OK. Once a unique column has an index, you cannot remove the index from that column, unless you first redefine the column to allow duplicate values.
How to create a look up column in SharePoint 2013 ,2010 ?
I am going to create a look up column in step by step process...Please follow the same .
1. Create a Custom List "TestListA" . Create a column "place (DataType: Multiline Text box I have taken as per my requirment) and add some data to it.
2. Create another List "TestListA". Now Create new column Name Place and select the datatype Lookup feild
3 After selecting the Column from the another list . Please click on the save button and then open the list and try to add new item.
4. At the time of creating the look up column if we select the "Allow multiple values" check box.
then the above form will be looking like below screen.
This is how we create a sample look up column in SharePoint 2010 as well as SharePoint 2013.
Hope this Post will help you .......
Tuesday, December 9, 2014
Get Alert box in SharePoint in C#.
Posted by
Santhosh,
on
3:10 AM
HI Guys ,
Thanks for visiting us .
If you want to display the Pop up or alert boxes in case of coding in SharePoint C# .
Please take the below line for your reference.
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record Inserted Successfully')", true);
Subscribe to:
Posts
(
Atom
)