Saturday, March 27, 2010

Customising Welcome message of the site

Hi,


There may be the situation where you may have to customise the welcome message which will be on the right top of the site.For that i got the good link.Now my requirement was displaying the message based upon the intranet/extranet site.For that initially i have written the below code in welcome.ascx but the problem is it use to execute if condition always


Finally after seeing the link


http://www.wictorwilen.se/Post/Having-fun-with-the-SharePoint-Welcomeascx-control.aspx


what i did is


I took a custom user controlcustomwelcome.ascx and copy pasted the code of welcome.ascx in it and I have wriiten code in webpart as


namespace CustomWelcome {


public class Welcome : Microsoft.SharePoint.WebControls.Welcome {


protected Welcome() {


}


[SharePointPermission(SecurityAction.Demand, ObjectModel = true)]


protected override void OnLoad(EventArgs e)


{


base.OnLoad(e);


if (HttpContext.Current.User.Identity.IsAuthenticated)


{


if (HttpContext.Current.User.Identity.AuthenticationType==”Forms”)


{


PostCacheSubstitutionText pt = base.ExplicitLogout.MenuControl.Controls[0]


as PostCacheSubstitutionText;


pt.TextType = PostCacheSubstitutionTextType.UserName;


pt.SuffixHtml=”(Extranet)”


}


Else


{


PostCacheSubstitutionText pt = base.ExplicitLogout.MenuControl.Controls[0]


as PostCacheSubstitutionText;


pt.TextType = PostCacheSubstitutionTextType.UserName;


pt.SuffixHtml=”(Intranet)”


}


}


}


}


}












No comments:

Post a Comment