Click here to Skip to main content
15,898,943 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Do you know how to hide textboxes and a button in my code when someone clicks the facebook Log In button on my web site. I use this code for my users to be able to login with facebook.

XML
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"  Inherits="_Default" %>
      <!DOCTYPE html>
     &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
     &lt;head runat="server">
    &lt;title>&lt;/title>
    <%--&lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.js">&lt;/script>--%>
    &lt;script src="//connect.facebook.net/en_US/all.js">&lt;/script>
    &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js">&lt;/script>
    <script type="text/javascript" src="jquery.maphilight.min.js">&lt;/script>
    </head>
    <body style="background-color:azure">
    &lt;script type="text/javascript">
        (function (d) {
            var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
            if (d.getElementById(id)) { return; }
            js = d.createElement('script'); js.id = id; js.async = true;
            js.src = "//connect.facebook.net/en_US/all.js";
            ref.parentNode.insertBefore(js, ref);
        }(document));

        // Init the SDK upon load
        window.fbAsyncInit = function () {
            FB.init({
                appId: '487818951287950', // App ID
                channelUrl: '//' + window.location.hostname + '/channel', // Path to your Channel File
                status: true, // check login status
                cookie: true, // enable cookies to allow the server to access the session
                xfbml: true  // parse XFBML
            });

            // listen for and handle auth.statusChange events
            FB.Event.subscribe('auth.statusChange', function (response) {
                if (response.authResponse) {
                    // user has auth'd your app and is logged into Facebook
                    FB.api('/me', function (me) {
                        if (me.name) {
                     document.getElementById('auth-displayname').innerHTML = me.name;
                        }
                    })
       document.getElementById('auth-loggedout').style.display = 'none';
       document.getElementById('auth-loggedin').style.display = 'block';
                } else {
                    // user has not auth'd your app, or is not logged into Facebook
       document.getElementById('auth-loggedout').style.display = 'block';
        document.getElementById('auth-loggedin').style.display = 'none';
                }
            });
            $("#auth-logoutlink").click(function () { FB.logout(function () { window.location.reload(); }); });
        }
    &lt;/script>
    &lt;form id="form1" runat="server">

        <div class="fb-login-button" id="fbkopce" runat="server">
       <div id="auth-status" >
     <div id="auth-loggedout" >

      <fb:login-button class="fb-login-button" autologoutlink="true"     scope="email,user_checkins">Најави се Facebook</fb:login-button>
      </div>
      <div id="auth-loggedin" style="display: none">
       Добредојде, <span id="auth-displayname"></span>(<a href="#" id="auth-logoutlink">одјави    се</a>)
       </div>
      </div>
      </div>

                <asp:TextBox ID="TextBox3" runat="server" Height="22px">username</asp:TextBox>   <br/>

                <asp:TextBox ID="TextBox4" runat="server" TextMode="Password"  ToolTip="Password">password</asp:TextBox><br />



        <asp:Button ID="Button1" runat="server" Text="Најави се!" OnClick="Button1_Click" />

        &lt;/form>


       &lt;/body>
      &lt;/html>
Posted
Updated 12-Jun-13 9:05am
v2
Comments
Sergey Alexandrovich Kryukov 12-Jun-13 16:44pm    
What's the problem? You are already using style.display. Just debug your code...
—SA
Dragan Jovanovski 12-Jun-13 17:10pm    
I want to know if the user is logged in or not with facebook and I want to check that with the if clause. example: if (user is logged in with fb){ textbox1.visible = false; }
Sergey Alexandrovich Kryukov 12-Jun-13 17:35pm    
"I want to know..." is not a problem, in this case: you have a full right to know that. The problem is: what goes wrong?
—SA

1 solution

…Alternatively, you can use CSS visibility property, as well as the corresponding style.visibility DOM element property you could modify in JavaScript: http://www.w3schools.com/cssref/pr_class_visibility.asp[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900