HTTP errors are returned to the client when something goes wrong on the server. Error status codes are returned if the requested file isn't found (404), or due to coding errors in the web page (500), and due to temporary issues such as failed database connections (500). The most common errors are 404 (file not found) and 500 (application) errors.
Check the following list of IIS errors
- 400 Error (bad request)
- 401 Error (unauthorized)
- 403 Error (forbidden)
- 404 Error (not found)
- 500 Error (internal server error)
How to Custom HTTP Errors?
To implement SharePoint support of the custom HTTP error you have to editing in WebConfig file by adding the below section inside <system.webServer> tag and then you can replace "/Pages/404.aspx" with your own dynamic page.
<httpErrors errorMode="Custom" existingResponse="Auto">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/Pages/404.aspx" responseMode="ExecuteURL" />
</httpErrors>
Actually the important part in the above snippet code is in <httpErrors errorMode="Custom" existingResponse="Auto"> because if you are working in SharePoint Config file you have to add to the httpErrors element setting error mode to custom and this will inform IIS to you out custom page.
Note:
This configuration is just supported in newest versions of IIS starting from IIS7
Created site definition by using SharePoint 2010 and visual Studio which correctly creates all lists and includes pages instances in Pages Document Library, these pages use the correct custom page layouts which using the custom content types and therefore the page doesn’t work as expected.
Then I opened the Library Settings from Pages Document Library and I didn’t find my custom content Type attached to the Pages Document Library.

So how we can attach Custom Content Types to lists like Pages document library?
We can attach our custom content types by the following steps:
1- Create new Empty Element Item and then write the below code with your content type ID in the Element.xml file
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentTypeBinding ContentTypeId="0x010100899F73B9F6814EA8AED9876985F28B46" ListUrl="Pages" />
</Elements>
2- Add new feature to the Site Definition project, this feature just contains the new element that is already created with the above code.
3- Add a feature dependency in the onet.xml file
<!-- Binds custom content types to Pages library.-->
<Feature ID="260a85fd-e9db-4e1a-aece-7d1c7caa3196">
</Feature>
4- Add each page in a module with the content type
<File Url="test.aspx" Type="GhostableInLibrary">
<Property Name="Title" Value="Test" />
<Property Name="ContentType" Value="Custom_ContentTypes_Publishing - CustomFive" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/Custo Page.aspx, $Resources:cmscore,PageLayout_WelcomeLinks_Title;" />
</File>
Finally you can deploy your package to the SharePoint and you will find your custom content types attached to the Pages Document Library.
Good luck and I hope this information is helpful to you and Please feel free to write your comment.
List Definition:
A list definition defines a schema for a SharePoint list. It contains information on what views are being used, which columns and content types are being used, and other metadata information.
List Template:
A list template can either be created by end users through the SharePoint user interface using an existing list as a pattern or using an existing list instance. If based on a user-created list it is called a custom list template. A custom list template includes everything that defines the list, including list columns and site columns used by the list, content types used by the list, views defined for the list, and so on.
Tips
A list template may sound like a list definition but they are effectively the same thing, a pattern for a SharePoint list. They differ mainly in how they are created:
- A list templates are created in SharePoint or SharePoint designer.
- A list definitions in Visual Studio.
List Instance:
A list instance is an instance of a specific SharePoint list definition or list template. All of its data is stored in the relevant content database. Typically a list in SharePoint used by end users to enter and view data and it is based on either a list template or list definition.
References:
Addison Wesley - SharePoint 2010 Development with Visual Studio 2010
If you are seeking to access control in a master page or aspx page files you have to use FindControl method.
The following code examples shows how to use the FindControl method to get a reference to controls so when using MasterPage file you will find controls rendered with prefix such as “ctl00$<ContentPlaceHolderID>$<NameYouGaveToControl>” according to their place in the page hierarchy so you must get reference to the ContentPlaceHolder first and then use FindControl mehtod to locate the control.
Example:
ContentPlaceHolder mpContentPlaceHolder =
(ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
if (mpContentPlaceHolder != null)
Button mpbtnSave = (Button)mpContentPlaceHolder.FindControl("btnSave");
Gets a reference to a Button control that not in a "ContentPlaceHolder".
Example:
Button mpbtnSave = (Button) Master.FindControl("btnSave");
Gets a reference to a Button control that is in aspx page and not in a MasterPage.
Example:
Button mpbtnSave = (Button) Page.FindControl("btnSave");
If you have two collection lists one of them for parent (Main Category) and other one for child (Sub Category) and you want to display both of them in one listbox but you want the parent item take back color different than the child, the below example code is showing how to do this.
//loop for parent collection list
foreach (var parentItem in objParentCollectionList)
{
//Set all back color items with blue
listBox1.BackColor = Color.Blue;
//inset parent items in listbox control
listBox1.Items.Add(new ListItem(mainItem.Name, mainItem.ID.ToString()));
//Get all childs by parent ID
objChildCollectionList = GetChildList(mainItem.ID);
if (objChildCollectionList != null)
{
//loop for child collection list
foreach (var childItem in objChildCollectionList)
{
ListItem listItem = new ListItem(childItem.Name, childItem.ID.ToString());
//change back color foe each child item
listItem.Attributes.Add("style", "background-color: Azure");
//inset child items in listbox control
listBox1.Items.Add(listItem);
}
}
}
Note:
listbox1.BackColor = Color.Blue; it will effect on all listbox items not on specific item
I created a blog site in SP2010 and I faced some problems and I will explain them step by step with each solution, after blog site created then from the Site Actions => Site settings, I didn’t find the master page feature enabled to change the custom development master page so you having to enable publishing features to be able to do this through the UI.
After applying the custom master page to change, the new master page did not render on the blog site.
And according to Microsoft Support (http://support.microsoft.com/kb/936908) this just happen if you using a template other than one of the templates on the Publishing tab of the New SharePoint Site page, and they suggested work around on this issue, to use system master to apply the custom master page and actually I don’t know if this is a bug in Microsoft or not but if you compelled you have to use this solution till now.
Good luck and I hope this information is helpful to you and please feel free to write your comment.
As usual we faced some problems in SharePoint 2010 during building without more clarification or description to know what is the error message means? so you have to investigate and search by yourself which part of the solution this problem? How to fix it?
but furthermore i am still like Microsoft :)
Error Message: Error occurred in deployment step 'Add Solution': Failed to extract the cab file in the solution.
This happen with me during deployment because there is image name in my layout folder contain brackets like "add(2).png" So you have to check if you have any files with special characters including brackets ' copy (2) filename ' and remove them.
Solution: To work around this problem, remove any parentheses in the names of SharePoint project items.
Here’s a list of some problems:
http://msdn.microsoft.com/en-us/library/ee330922.aspx
This post just a slight tip for showing the difference between Int32.parse(string) and Convert.ToInt32(string)
Int32.parse(string)
- Int32.Parse(string str) method converts the string representation of a number to integer 32 bit.
- when str is a null reference it will throw ArgumentNullException.
- if str is other than integer value it will throw FormatException.
- when str represents a number less than MinValue or greater than MaxValue it will throw OverflowException.
Convert.ToInt32(string)
- Convert.ToInt32(string str) method converts the string representation of a number to integer 32 bit.
- when str is a null reference it will return 0 rather than throw ArgumentNullException.
- if str is other than integer value it will throw FormatException.
- when str represents a number less than MinValue or greater than MaxValue it will throw OverflowException.
In this post I am going to show step by step how to format the datetime in your own item style in sharepoint 2010
1- Open your top-level site in Sharepoint Designer, click “All Files – Style Library – XSL Style Sheets – ItemStyle.xsl” and click Edit, I prefer to get a backup from this file before do any changes.
2- In the top of the file, add this line so we can format the date further down the road:
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
3- Add this at the bottom of the variables section:
<xsl:variable name="Created">
<xsl:value-of select="ddwrt:FormatDateTime(string(@Created) ,1033 ,'dd/MM/yyyy')" />
</xsl:variable>
The following lists of the language packs that are available for Office SharePoint Server 2010.
Arabic Saudi Arabia (Hijri) 1025
English United States 1033
4- Then you can use the variable
<strong><xsl:value-of select="$Created"/></strong>
Full Sample:
<xsl:template name="Test_template" match="Row[@Style='Test_template']" mode="itemstyle">
<xsl:variable name="CurrentDate">
<xsl:value-of select="ddwrt:FormatDateTime(string(@Date) ,1025 ,'yyyy/MM/dd')" />
</xsl:variable>
<div style="width:400px; height:100px;text-align:right;">
<div style="text-align:right;">
<xsl:value-of select="$CurrentDate"/>
</div>
</div>
</xsl:template>
Please check the below table and just remember that NULL means “unknown”
The expressions in this list always return NULL:
|
If A and B are NULL, then:
|
Is:
|
Because:
|
|
1 + 2 + 3 + A
|
NULL
|
If A is unknown, then 6 + A is also unknown.
|
|
'Home ' || 'sweet ' || A
|
NULL
|
If A is unknown, 'Home sweet ' || A is unknown.
|
|
MyField = A
|
NULL
|
If A is unknown, you can't tell if MyField has the same value...
|
|
MyField <> A
|
NULL
|
...but you also can't tell if MyField has a different value!
|
|
A = B
|
NULL
|
With A and B unknown, it's impossible to know if they are equal.
|
|
not (A)
|
NULL
|
If A is unknown, its inverse is also unknown.
|
The above table will help you at many cases that you want to use null so we will take a sample to make this list very easy and clear for you, like If you are looking to create SQL query for using it in search to get data from employee table according to some search criteria
Employee Table:
|
ID
|
EmployeeName
|
|
1
|
Karim Hasan
|
|
2
|
Karim
|
|
3
|
Ola Ali
|
1- This query return all rows just if the name is equal "Karim"
Set @name = 'Karim'
select * from Employee where EmployeeName = @name
Result
--------------------------
ID EmployeeName
2 Karim
2- This query return all rows contains name "Karim"
Set @name = 'karim'
select * from Employee where EmployeeName like '%' + @name + '%'
Result
--------------------------
ID EmployeeName
1 Karim Hasan
2 Karim
The above samples are not my point there are jsust initiative my point is, if you want once the user pressed on the search button in you application without enter any data like "Employee Name" then return all the employees from the employee table and this means you are going to set @name parameter with NULL value (Set @name = null), how can we do that??
Honestly there are many ways to do that and I will list two samples one of them is the best at latest for me depend in NULL expression and I prefer to use it in my work.
Sample 1:
Declare @name varchar(20)
Declare @Sql varchar(1000)
set @name = 'Karim'
select @Sql ='select * from Employee where 1 = 1'
If (@name is not null)
Begin
select @Sql = @Sql + ' and EmployeeName like ''%' + @name + '%'''
End
exec(@Sql)
Sample 2:
Declare @name varchar(20)
set @name = 'Karim'
select * from Employee where EmployeeName = IsNull ( '%' + @name + '%', EmployeeName)
when you take a look in this statement at the first time "IsNull ( '%' + @name + '%', EmployeeName)" you will say how isnull function will return null without to check in this char '%', but as we list before in the above table that if you are using Null in an expression returns null
Select 1 +2
Result: 3
Select 1+Null
Result: Null
Select '%' + Null
Result: Null
I prefer the sample 2 by using NULL expression because it is very easy and as you see we don't need to write many lines of code to write quires for search.
Good luck, and I hope this information is helpful to you and Please feel free to write your comment.