I work in a financial company where we have Resident Engineers and they have account in Active Directory but they dont have official email addresses.
My portal acrhitecture is like everyonce can visit portal and on my Home.aspx I have a Content Editor Webpart in which I have a link called "Purchase Requisition" which is valid for the users who has email addresses of the company.
When user opens the new requisition custom form (A Visual Webpart) actually it checks the user name and then try to locate the email addresses in my Hiererchy list and if found it retrieves the user information and display and it opens this requisition form in Modal Dialog.
What I want is if those users who has no company email addresses opens the portal then the CEWP which contains Requisition link should be hidden.
i got this code from somewhere how and where should I use it in this condition? or is there any javascript way to query list and seek value and based on that value hide and unhide webpart?
PWeb myWeb = SPContext.Current.Web;
myWeb.AllowUnsafeUpdates = true;
Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager mgr = null;
mgr = myWeb.GetLimitedWebPartManager(
"default.aspx",
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
foreach (System.Web.UI.WebControls.WebParts.WebPart myWebPart in mgr.WebParts)
{
// If this is the webpart we want to change...
if (myWebPart.Title == "SomeWebpartName")
{
myWebPart.Hidden = true;
mgr.SaveChanges(myWebPart);
break;
}
}