Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I created a site with anonymous access and forms based authentication. Now I want to show the link to create a new user in the master page when ever no one is signed in. Can any one please help to achieve this process? Following are the screen shots for more details. enter image description here enter image description here

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

You could add a delegate control and user control to check to your master page, and check if the user is anonymous then show the link :)

Add a Delegate control to your master page:

   <SharePoint:DelegateControl runat="server" ControlId="PageHeader">
    </SharePoint:DelegateControl>

Only thing to note here at this stage is the ControlId attribute - the Feature we create will use this to substitute the real user/server control.

Then we have the feature.xml file, where we specify the feature details (including scope):

<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Id="373042ED-718D-46e2-9596-50379DA4D522"
Title="COB.Demos.DelegateControls"
Description="Specifies which user control should be used for the 'PageHeader' DelegateControl used on the site master page. The replacement user control is stored in the CONTROLTEMPLATES directory." Scope="Farm"
Hidden="FALSE"
Version="1.0.0.0">
<ElementManifests>
<ElementManifest Location="elements.xml"/>
</ElementManifests>
</Feature>

the 'instructions' for the feature are in the element manifest:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- using a sequence number LOWER than default of 100 so our custom control gets loaded -->
<Control Id="PageHeader" Sequence="90" ControlSrc="~/_ControlTemplates/COBPageHeader.ascx" />
</Elements>

In the COBPageHeader.ascx code-behind, add the logic of hiding link.

share|improve this answer
    
For anonymous we have to show the link to register... :) –  Mihir Nov 9 '12 at 11:32
    
ok, whatever ;), but hopefully you will develop it :) –  Falak Mahmood Nov 9 '12 at 12:02
    
Here Instead of that feature.xml and element.xml we can do one thing. Just add an empty element and refer the control id and other parameters. Just change the scope of the feature in feature editor scree. Thats it.! this way works successfully!! Thank you brother –  Mihir Nov 9 '12 at 12:10
add comment

I have recently made use of this feature, made use of a delegate control to accomplish this

share|improve this answer
    
Welcome to SharePoint StackExchange. Although your answer may answer the question, there isn't enough content to produce a suitable working solution. Please read the FAQ[1] for more information [1]:sharepoint.stackexchange.com/faq –  Hugh Wood Dec 2 '12 at 3:24
add comment

You can check if the CurrentUser has a LoginName which is not an empty string attached to the SPContext.Current.User object. If the LoginName is null or empty, then the user is anonymous.

Code here: http://spdailytips.blogspot.in/2011/09/programmatically-verify-if-current-user.html

You can write the code in a delegate control which will be attached to the Master Page. The Delegate Control will check If the user is anonymous, and if yes, push the link to the page.

share|improve this answer
    
thank you.. But where I want to add that user checking code in master page? –  Mihir Nov 9 '12 at 10:21
    
Just search for how to add a delegate control to a page –  Vardhaman Deshpande Nov 9 '12 at 11:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.