SharePointAds TextOnly

Friday, 25 December 2009

Sharepoint: How to manage Feature activation dependency?

In Sharepoint need to manage the dependencies in different features

For exp: Need to activate Feature A before activation of Feature B, So add below lines in Feature.xml file in Feature B before < / Feature > tag

< ActivationDependencies >

< ! -- Feature A’s ID - - >

< ActivationDependency FeatureId = " D4000102-848E-4434-A1C5-C60C862F429C " / >

< / ActivationDependencies >

Refere feature A’s ID.

(*Please remove spaces in tags..)

Thursday, 5 November 2009

Sharepoint: How to create new custom permission level?

We can create custom permission levels and assign to site users.

How to create new custom permission level?
1. Goto Site Setting

2. Select Advance Permission
3. Goto Setting and click on Permission level
4. It will open new page, then click on Add a Permission level
5. Give Name, description for this new permission level select permissions from list as per your need.
6. Click on Create, It will display on permission level page.

How to assign this new permission to users?
1. Goto Site Setting
2. Select People and groups
3. Click on New Menu and select Add user
4. enter user name on people picker box, and select "
" radio button
5. Find
newly created permission level click on check box to assign user under this permission
6. Click on OK


Wednesday, 30 September 2009

difference between Authorization and Authentication?

Authentication :
Authentication is a process of identifying a user based on their credentials(means user id and password).

Authorization :
Authorization is process of determining whether an authenticated user is allowed to access a specific resource or not.


In Short,
Authentication is the process of validating a logged in person with user_id and password
Once a person is authenticated, Authorization is the process who check the person access or not for some places.

The "quick guide"
Identification : Who are you?
Authentication : Prove yourself
Authorization : Here is what you can do?

Monday, 21 September 2009

Sharepoint:Add new link to Quick Launch, Programmatically and through site settings

We can add new link to Quick launch menu by two ways
i. By Site Setting
ii. By Programmatically



1. How to add new link by Site settings?
Follow the following steps:
a. Login by admin authentication
b. Goto Site Action -> Site Settings
c. Click on 'Quick Launch' under 'Look and Feel' section
d. Click on 'Select Heading' and add 'Web Address' where you want to redirect (I use '#' which redirects to default.aspx page)and then give new name for this new section in 'description' text box(I use 'Custom Menu').
e. Click on OK, this will create new section in Quick Launch menu
f. Then click on 'New Link', it will open new window
g. Provide web address, and description (I use '/MyCustomPage.aspx' and give name as 'My Custom Page', this name will displaying in Quick launch menu)
i. Then select heading from combo box, select 'Custom Menu' heading
j. click on OK button
k. Now click on Home or goto default.aspx page


2. How can we create Quick Launch menu Programmatically?
use following code:

SPWeb web = SPContext.Current.Site.RootWeb;
web.AllowUnsafeUpdates = true;

SPNavigationNodeCollection nodes = web.Navigation.QuickLaunch;
SPNavigationNode navNode = new SPNavigationNode("Custom Menu", "#", false);
nodes.AddAsFirst(navNode);

SPNavigationNode headerLink1 = new SPNavigationNode("My Custom Page", "/MyCustomPage.aspx", true);
nodes[0].Children.AddAsFirst(headerLink1);


This will create new section in Quick lauch menu..
Really soooo easy :)

Friday, 4 September 2009

Sharepoint: Error while sending email alerts thro' sharepoint site

sometimes sharepoint email alerts are not properly working, and its very difficult to find actual error cause.
I also faced lots of problem with same issue, on development server alerts works like charm but on installable server, email alerts not working..
I searched for solution but didn't get anything, all outgoing email configuration in Central Admin correct.

So i checked email error from following utility, you can download from
http://www.codeplex.com/rodneyviana/Release/ProjectReleases.aspx?ReleaseId=19103

you can extract only the .exe file (SendMail\bin\Debug\SendMail.exe) and run it without any installation. This application will send an e-mail. Enter the url of a valid sharepoint site and a valid user login name for that site which will be the recipient of the test email message. The application will display the e-mail information from the sharepoint site user login name.

for more information please have a look at
http://blogs.msdn.com/rodneyviana/archive/2008/11/06/how-to-test-the-mail-settings-for-a-sharepoint-web-application.aspx

Thursday, 27 August 2009

Sharepoint: How to get MAX id of list?

How can we get MAX id of any present list?
-> Simplely use following code
(*Note: insert your list name rather ' List_Name ')

public string MaxListId()
{
SPWeb web = SPContext.Current.Web;
SPList oList = web.Lists[" List_Name "];
SPQuery query = new SPQuery();

query.Query = " ";
SPListItemCollection items = oList.GetItems(query);

DataTable dtmax = new DataTable();
dtmax = items.GetDataTable();

string maxId = "";
foreach (DataRow row in dtmax.Rows)
{
maxId = row["ID"].ToString();
break;
}

return maxId;
}


--

Sharepoint : How to redirect list form URL's?

We can redirect sharepoint's default New/Edit/display forms by our new created custom forms..

SPList list = web.Lists["listName"];
SPContentType ct = list.ContentTypes["Item"];

ct.NewFormUrl = "NewCustomForm.aspx";
ct.EditFormUrl = "NewEditForm.aspx";
ct.DisplayFormUrl = "NewDisplay.aspx";
ct.Update();

newVendorList.Update();


-

Sharepoint: Programatically add LookUp field to custom list

We can add programmatically other 'LookUp' field as a new column into custom list, simply add below code.. :)

SPList targetList = web.Lists["List1"];
list.Fields.AddLookup("Col2", targetList.ID, false);
SPFieldLookup lookupField = list.Fields["Col2"] as SPFieldLookup;
lookupField.LookupField = targetList.Fields[SPBuiltInFieldId.Title].InternalName;
lookupField.Update();

Suppose we have two different list List1 and List2, and in List1 have three columns as col1, col2, col3.
So with above code, it creates new lookup field as 'Col2' column in List2.


-

Friday, 21 August 2009

Sharepoint : Want to create new simple application site in sharepoint?

Just do following steps to create simple sharepoint new site with VS2008.

1. Create new sharepoint project, select "Empty" template, give name for your project
2. Now right click on your project, select 'Add'>New Item and select "Module" from sharepoint template, give name (keep in mind this is your feature name...)
3. It automatically creates Module.xml (you can called as element.xml) and sample.txt
4. Add custom pages or do any think what you want
5. Simply press F5, then automatically create solution, copy assemply to GAC, also create new feature folder in 12 hive, and deploy in your sharepoint site...


its soo simple :)

*Note: To add new sharepoint template in VS 2008, please WSS 3.0 extension for VS 2008.

Friday, 7 August 2009

.Net: Difference between String and Stringbuilder?

Usually, String is immutable type which means once you have the content there then you can't change it. While StringBuilder is mutable because it allows you to change the content that you have already placed.
Important to keep in mind that a string allows you to change the content but offcourse it always creates a new string reference. For example, all string methods return a new string and don't update the same string variable.
When you have huge amount of concatenation, best recommendation to go for StringBuilder!
Example:
String and StringBuilder class stores strings. But when you cannot change a String object after creating one.
eg: String name = "Test";
By saying you can't change the name object means you can't change the value in name object internally. When you change the name object value to something else, a new String object is creating in memory and assign the new value.

eg: name = "Test Example";

A new name object is creating in memory and the value "Test Example" is assinging to the newly created space.

But StringBuilder class occupies the same space even if you change the value.
If you are doing string concatenation StringBuilder class is far better in performance than String class.

You can use StringBuilder's Append() method to use concatenation.


also check this link Example

Saturday, 25 July 2009

How to change 'Title' column of any list? (Programmatically!!)

-use this!!

SPList list = web.Lists["listName"];
//Change the Title column name to "vendor_name"
list.Fields["Title"].Title = "Vendor_Name";
list.Fields["Title"].Description = "Vendor Name";
list.Fields["Title"].Update();

Tuesday, 23 June 2009

Sharepoint: Show errors on web pages

sharepoint development is really tooo buggy solution for development/debugging, also it doesn't show any error after deploying your solution.
To show errors in sharepoint, do the following changes on web.config of your sharepoint site
(* your sharepoint site Path : Inetpub\wwwroot\wss\VirtualDirectories\yoursite\web.config)

Find: < SafeMode CallStack="false"
Replace with: < SafeMode CallStack="true"

Find: < customErrors mode="On"
Replace with: < customErrors mode="Off"

Find: < compilation debug="false"
Replace with: < compilation debug="true"


Save the changes, it show all errors on your checked pages...


its really so simple to debug with above.. :)

Friday, 19 June 2009

Java :Add Logger system

1. download log4j.jar file
2. Add into our Java project libraries
3. Create new properties file at root with name "log4j.properties" and copy and paste following code

# Log levels
# Uncomment the following line to enable full loggin for every class
#log4j.rootLogger=trace, stdout, R
log4j.logger.gr.xfrag=trace, stdout, R

# Console appender configuration
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

# Rolling File Appender
log4j.appender.R=org.apache.log4j.RollingFileAppender
# Path and file name to store the log file.
log4j.appender.R.File=./logs/applog.log
log4j.appender.R.MaxFileSize=500KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
# Rolling File Appender layout
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d - %c - %p - %m%n

4. Add following code on class/web-page,

private org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(this.getClass());
log.setLevel(org.apache.log4j.Level.ALL);
log.debug( request.getRemoteAddr() + " This is Index page log ");

Note: request.getRemoteAddr() gives IP address where web page is called.

It stores the log file on 'C:\Program Files\Apache Software Foundation\Tomcat 6.0' with Demo.log file, creates all new logs with following formate
2009-06-06 20:29:02,562 - org.apache.jsp.index_jsp - DEBUG - 0:0:0:0:0:0:0:1 This is Index page log

If you want to use GUI to read logger files then use LogMX(v1.3.2).
1. Create new formate parser. Goto Tools > Option.
2. It opens new option window, Under Parsers tags create new parser formate .
3. It shows new 'Add a log file parser' window, under log4j pattern parser add new patter which is used in "log4j.properties".
4. It parse your logger file.

Saturday, 9 May 2009

SharePoint:customize FBA default login page

If you have using 'Form Based Authentication(FBA)' to your sharepoint site then by default it is showing login page from its internal page.
I found the login page on

C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\TEMPLATE\LAYOUTS

We were customize old give above provided page to add forgot password link.

To customize the login.aspx page then follow following URL.
http://www.simple-talk.com/dotnet/.net-tools/customizing-the-login-page-in-sharepoint-2007/