allow useing JavaScript links in RegisterLink and LoginLink

This forum is for questions about contributing to the project or proposing features that you would like to develop for the project. 

This thread is closed to new posts. You must sign in to post in the forums.
4/17/2011 1:40:08 AM
Gravatar
Total Posts 23
Ahmed Ali Senior Developer

allow useing JavaScript links in RegisterLink and LoginLink

Hi Joe 

i have modified the LoginLink.cs and RegisterLink.cs to allow useing JavaScript links in CustomRegistrationPage and LoginPageRelativeUrl this will help if we need to make a login dialog using jquery and we can do a nice login or register popups by javascriopt

just add the following lines ...

in LoginLink.cs at line number 135 before WriteBeginTag

            /////  allow useing JavaScript links Added By Ahmed Ali on 2011-04-17
            if (SiteUtils.GetLoginRelativeUrl().StartsWith("JavaScript"))
            {
                urlToUse = SiteUtils.GetLoginRelativeUrl();

            }
            ///// End allow useing JavaScript links

 

 

in RegisterLink.cs at line number 142 before WriteBeginTag

            /////  allow useing JavaScript links Added By Ahmed Ali on 2011-04-17

           if (WebConfigSettings.CustomRegistrationPage.StartsWith("JavaScript"))

            {
                urlToUse = WebConfigSettings.CustomRegistrationPage;

            }
            ///// End allow useing JavaScript links

 

and i have send the both files to your mail 

thanks 

 

 

 

 

 

4/17/2011 5:57:23 AM
Gravatar
Total Posts 18439

Re: allow useing JavaScript links in RegisterLink and LoginLink

Hi Ahmed,

Sorry but I do not agree with these changes, they are not needed.

Using href="JAVASCRIPT:...." is a bad idea because then the link does not work at all if javascript is disabled.

It is far better to use unobtrusive javascript. If you want to wire up something to the click event of the register link for example you can do it easily and unobtrusively from layout.master like this:

<portal:RegisterLink id="RegisterLink" runat="server" CssClass="sitelink registerlink" RenderAsListItem="true" />

<script type="text/javascript">
            $(document).ready(function () {
                $("a.registerlink").click(function(){ ... });
                    });
        </script>

Doing it this way means the link can still work normally if javascript is disabled.

Best,

Joe

4/17/2011 6:46:50 AM
Gravatar
Total Posts 23
Ahmed Ali Senior Developer

Re: allow useing JavaScript links in RegisterLink and LoginLink

Hi Joe

Thank you and you are definitely better

Actually use JavaScript to do will be a good idea

I am happy always to learn from your experience

You must sign in to post in the forums. This thread is closed to new posts.