Saturday, 21 December 2013

Loading Before Page Load using css.

<html>
<script language="javascript" type="text/javascript">
    $(window).load(function () {
        $(".loader").fadeOut("slow");
    });  
</script>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<style>
.loader2{  
z-index: 10010;     position: fixed;     padding: 0px;     margin: 0px;     width: 30%;     top: 40%;     left: 35%;     text-align: center;     color: rgb(0, 0, 0);     border: 0px solid rgb(170, 170, 170);     cursor: wait;
}
.loader-bg-color
{
z-index: 9999; border: medium none; margin: 0px; padding: 0px; width: 100%; height: 100%; top: 0px; left: 0px; background-color: rgb(0, 0, 0); opacity: 0.6; cursor: wait; position: fixed;}
#bowl_ringG{position:absolute;width:50px;height:50px;border:4px solid #908B91;-moz-border-radius:50px;-webkit-border-radius:50px;-ms-border-radius:50px;-o-border-radius:50px;border-radius:50px;left:50%;
}
.ball_holderG
{
position:absolute;width:13px;height:50px;left:18px;top:0px;-moz-animation-name:ball_moveG;-moz-animation-duration:0.8s;-moz-animation-iteration-count:infinite;-moz-animation-timing-function:linear;-webkit-animation-name:ball_moveG;-webkit-animation-duration:0.8s;-webkit-animation-iteration-count:infinite;-webkit-animation-timing-function:linear;-ms-animation-name:ball_moveG;-ms-animation-duration:0.8s;-ms-animation-iteration-count:infinite;-ms-animation-timing-function:linear;-o-animation-name:ball_moveG;-o-animation-duration:0.8s;-o-animation-iteration-count:infinite;-o-animation-timing-function:linear;animation-name:ball_moveG;animation-duration:0.8s;animation-iteration-count:infinite;animation-timing-function:linear;
}
.ballG
{
position:absolute;left:0px;top:-12px;width:20px;height:20px;background:#FF9933;-moz-border-radius:17px;-webkit-border-radius:17px;-ms-border-radius:17px;-o-border-radius:17px;border-radius:17px;
}

@-moz-keyframes ball_moveG{
    0%{-moz-transform:rotate(0deg)}
    1000%{-mo0z-transform:rotate(360deg)}
}

@-webkit-keyframes ball_moveG{
    0%{-webkit-transform:rotate(0deg)}
    100%{-webkit-transform:rotate(360deg)}
}

@-ms-keyframes ball_moveG{
    0%{-ms-transform:rotate(0deg)}
    100%{-ms-transform:rotate(360deg)}
}

@-o-keyframes ball_moveG{
    0%{-o-transform:rotate(0deg)}
    100%{-o-transform:rotate(360deg)}
}

@keyframes ball_moveG{
    0%{transform:rotate(0deg)}
    100%{transform:rotate(360deg)}
}



</style>
<body>
    <div class="loader">
        <div class="loader-bg-color">
        </div>
        <div class="loader2">
            <div id="bowl_ringG">
                <div class="ball_holderG">
                    <div class="ballG">
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

Tuesday, 4 June 2013

IIS Configuration for HTTPS:

IIS Manager
OBTAIN A CERTIFICATE
Select the server node in the treeview and double-click the Server Certificates feature in the listview:



Click Create Self-Signed Certificate... in the Actions pane.




 Enter a friendly name for the new certificate and click OK.
Now you have a self-signed certificate. The certificate is marked for "Server Authentication" use; that is, it uses as a server-side certificate for HTTP SSL encryption and for authenticating the identity of the server.

CREATE AN SSL BINDING

Select a site in the tree view and click Bindings... in the Actions pane. This brings up the bindings editor that lets you create, edit, and delete bindings for your Web site. Click Add... to add your new SSL binding to the site.


The default settings for a new binding are set to HTTP on port 80. Select https in the Type drop-down list. Select the self-signed certificate you created in the previous section from the SSL Certificate drop-down list and then click OK.


Now you have a new SSL binding on your site and all that remains is to verify that it works.



VERIFY THE SSL BINDING

In the Actions pane, under Browse Web Site, click the link associated with the binding you just created.


Internet Explorere (IE) 7 and above will display an error page because the self-signed certificate was issued by your computer, not by a trusted Certificate Authority (CA). IE 7 and above will trust the certificate if you add it to the list of Trusted Root Certification Authorities in the certificates store it on the local computer, or in Group Policy for the domain. 
Click Continue to this website (not recommended).

CONFIGURE SSL SETTINGS

Configure SSL settings if you want your site to require SSL, or to interact in a specific way with client certificates. Click the site node in the tree view to go back to the site's home page. Double-click the SSL Settings feature in the middle pane.


Tuesday, 14 May 2013

Show Popup Like a Model Popup


Show Div Like a ModelPopup:

Write Top of the ASPX page (in a content if masterpage is there)

<style>
.top_block
{
    position: absolute;
    display: block;
    min-height: 50px;
    width: 275px;
    z-index: 1001;
    background: white;
    margin-left: -234px;
    left: 58%;
    top: 10%;
    border: 6px solid white;
    border-radius: 10px 10px;
    -moz-border-radius: 10px 10px;
    padding: 15px;
    background: url("../images/line_divider.png") no-repeat scroll right center #E6E6E6;
}
.popup-boxclose
{
    float: left;
    height: 39px;
    left: 275px;
    position: absolute;
    top: -40px;
    width: 40px;
    z-index: 9999;
    cursor: pointer;
}

.translucent_cover
{

position: absolute;
display: block;/*
height: 1500px;
width: 2000px;*/
height:100%;
width:100%;
top: 0;
left: 0;
z-index: 1000;
background: black;
-moz-opacity: 0.8;
opacity:.80;
/*margin-top: -300px;
margin-left: -100px;*/
filter: alpha(opacity=80);
}


</style>
<script language=”Javascript”>

function close_pop() {
    document.getElementById("overlay").style.display = 'none';
    document.getElementById("top_block").style.display = 'none';
    $("body").css("overflow", "auto");
}

function pop() {
    $("body").css("overflow", "hidden");
    document.getElementById("overlay").style.display = 'block';
    document.getElementById("top_block").style.display = 'block';
}
</script>

  <div class="translucent_cover" id="overlay" style="display:none;">
    </div>
    <div class="top_block" id="top_block" style="display:none;">
        <div id="Error-boxclose" class="popup-boxclose">
            <img width="40" height="39" alt="" src="images/close-icon.png" onclick="close_pop()">
        </div>       
        <div id="ValidationSummeryFromJS" class="PopUpScroll">
        </div>       
    </div>
<img width="40" height="39" alt="" src="images/open-icon.png" onclick="pop()">






How to get Previous Page URL without using session or Querystring?


How to get Previous Page URL without using session or Querystring?


From Code Behind file write:



Uri MyUrl = Request.UrlReferrer;
            if (MyUrl != null)
                ViewState["ReturnURL"] = Convert.ToString(Request.UrlReferrer.AbsoluteUri);



Friday, 15 February 2013

FaceBook Cover Albums Access Through Asp.net c#



Create one appication in facebook from Developers page.

Then Create these pages:


oAuthFacebooks.cs:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections.Specialized;
using System.Net;
using System.IO;

/// <summary>
/// Summary description for oAuthFacebooks
/// </summary>
public class oAuthFacebook
{
    public enum Method { GET, POST };
    public const string AUTHORIZE = "https://graph.facebook.com/oauth/authorize";
    public const string ACCESS_TOKEN = "https://graph.facebook.com/oauth/access_token";
    public const string CALLBACK_URL = "http://localhost:3160/WebSite17/fbcallback.aspx";

    private string _consumerKey = "";
    private string _consumerSecret = "";
    private string _token = "";

    #region Properties

    public string ConsumerKey
    {
        get
        {
            if (_consumerKey.Length == 0)
            {
                _consumerKey = "############"; //Your application ID
            }
            return _consumerKey;
        }
        set { _consumerKey = value; }
    }

    public string ConsumerSecret
    {
        get
        {
            if (_consumerSecret.Length == 0)
            {
_consumerSecret = "###########"; //Your application secret
            }
            return _consumerSecret;
        }
        set { _consumerSecret = value; }
    }


    public string Token { get { return _token; } set { _token = value; } }

    #endregion

    /// <summary>
    /// Get the link to Facebook's authorization page for this application.
    /// </summary>
    /// <returns>The url with a valid request token, or a null string.</returns>
    public string AuthorizationLinkGet()
    {
        return string.Format("{0}?client_id={1}&redirect_uri={2}&scope={3}", AUTHORIZE, this.ConsumerKey, CALLBACK_URL,"user_photos");
    }

    /// <summary>
    /// Exchange the Facebook "code" for an access token.
    /// </summary>
    /// <param name="authToken">The oauth_token or "code" is supplied by Facebook's authorization page following the callback.</param>
    public void AccessTokenGet(string authToken)
    {
        this.Token = authToken;
        string accessTokenUrl = string.Format("{0}?client_id={1}&redirect_uri={2}&client_secret={3}&code={4}",
        ACCESS_TOKEN, this.ConsumerKey, CALLBACK_URL, this.ConsumerSecret, authToken);

        string response = WebRequest(Method.GET, accessTokenUrl, String.Empty);

        if (response.Length > 0)
        {
            //Store the returned access_token
            NameValueCollection qs = HttpUtility.ParseQueryString(response);

            if (qs["access_token"] != null)
            {
                this.Token = qs["access_token"];
            }
        }
    }

    /// <summary>
    /// Web Request Wrapper
    /// </summary>
    /// <param name="method">Http Method</param>
    /// <param name="url">Full url to the web resource</param>
    /// <param name="postData">Data to post in querystring format</param>
    /// <returns>The web server response.</returns>
    public string WebRequest(Method method, string url, string postData)
    {

        HttpWebRequest webRequest = null;
        StreamWriter requestWriter = null;
        string responseData = "";

        webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
        webRequest.Method = method.ToString();
        webRequest.ServicePoint.Expect100Continue = false;
        //webRequest.UserAgent = "[You user agent]";
        webRequest.UserAgent = "http://localhost:3160/website17/";
       
        webRequest.Timeout = 20000;

        if (method == Method.POST)
        {
            webRequest.ContentType = "application/x-www-form-urlencoded";

            //POST the data.
            requestWriter = new StreamWriter(webRequest.GetRequestStream());

            try
            {
                requestWriter.Write(postData);
            }
            catch
            {
                throw;
            }

            finally
            {
                requestWriter.Close();
                requestWriter = null;
            }
        }

        responseData = WebResponseGet(webRequest);
        webRequest = null;
        return responseData;
    }

    /// <summary>
    /// Process the web response.
    /// </summary>
    /// <param name="webRequest">The request object.</param>
    /// <returns>The response data.</returns>
    public string WebResponseGet(HttpWebRequest webRequest)
    {
        StreamReader responseReader = null;
        string responseData = "";

        try
        {
            responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream());
            responseData = responseReader.ReadToEnd();
        }
        catch
        {
            throw;
        }
        finally
        {
            webRequest.GetResponse().GetResponseStream().Close();
            responseReader.Close();
            responseReader = null;
        }

        return responseData;
    }
}


Default.aspx.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        oAuthFacebook oFB = new oAuthFacebook();
        Response.Redirect(oFB.AuthorizationLinkGet());
    }
}


Fbcallback.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class FBcallback : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["code"] != null)
        {
            string code = Request.QueryString["code"].ToString();
            oAuthFacebook fbAC = new oAuthFacebook(); //Standard FB class file available on net in c#
            string respnse = "";
            try
            {
                fbAC.AccessTokenGet(code);
                respnse = fbAC.Token;
            }
            catch (Exception ex)
            {
                Response.Redirect("http://localhost:3160/WebSite17/SiteLogin.aspx?error=" + ex.Message);
            }

            if (Session["RedirectURL"] != null && Session["RedirectURL"].ToString() != "")
            {
                Response.Redirect(Session["RedirectURL"].ToString() + "?token=" + respnse + "&source=FB");
            }
            else
            {
                Response.Redirect("http://localhost:3160/WebSite17/SiteLogin.aspx?token=" + respnse);
            }
        }
        else
        {
            Response.Redirect("http://localhost:3160/WebSite17/SiteLogin.aspxerror=code not found" +
                              Request.QueryString["error_reason"].ToString());
        }              
                
    }
}



SiteLogin.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

public partial class SiteLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string token = Request.QueryString["token"];       

        string HitURL = string.Format("https://graph.facebook.com/me/albums?fields=name&access_token={0}", token);

        oAuthFacebook objFbCall = new oAuthFacebook();
        string JSONInfo = objFbCall.WebRequest(oAuthFacebook.Method.GET, HitURL, "");   


        JObject Job = JObject.Parse(JSONInfo);
        JToken Jdata = Job.Root;
        JArray jsonVal = Job.Root["data"] as JArray;
      
        string Coverphotoid = null;
        foreach (var j1 in jsonVal)
        {
            if (j1.Value<string>("name").Equals("Cover Photos"))
                Coverphotoid = j1.Value<string>("id");
        }

        HitURL = string.Format("https://graph.facebook.com/{0}/photos?access_token={1}", Coverphotoid, token);

        objFbCall = new oAuthFacebook();
        JSONInfo = objFbCall.WebRequest(oAuthFacebook.Method.GET, HitURL, "");
        Job = JObject.Parse(JSONInfo);
        Jdata = Job.Root;
        jsonVal = Job.Root["data"] as JArray;
        foreach (var j1 in jsonVal)
        {
      Response.Write(Coverphotoid = j1.Value<string>("source") + " <br />" );
        }
    }
}


Click here for Download Newtonsoft.dll