Friday, April 26, 2013

Adding a New verb and give access to specific user on verbs in webpart share point 2010

 add this Code in your web part class in 
 public override WebPartVerbCollection Verbs property and change it according to your Requirement



 using (SPSite spSite = new SPSite("http://abc.com/"))
                using (SPWeb spWeb = spSite.OpenWeb())
                {
                    if (spWeb.CurrentUser.Name == "Customize" || spWeb.CurrentUser.Name == "abc\\Customize")
                    {
                        WebPartVerb configureSettingsVerb = new WebPartVerb("ConfigureSettings", ConfigureSettingsClickEventHandler);
                     

                        configureSettingsVerb.Text = "Configure Settings";
                        configureSettingsVerb.ImageUrl = "../../../_layouts/images/icon-controllerConfiguration.png";
                     
                        WebPartVerbCollection newVerbs = new WebPartVerbCollection(new WebPartVerb[] { configureSettingsVerb });
                        return (new WebPartVerbCollection(base.Verbs, newVerbs));
                    }


                    return (new WebPartVerbCollection(null, null));

No comments:

Post a Comment

How to Build interactive Design in Power Pages

 Need to Create a design in figma/or any UX tool Create a Power pages site. Create new Page Open page in VS Code in every page there are the...