Wednesday, 23 April 2014

Redirect Page with Querystring in MVC



return RedirectToAction("MethodName", new { categoryId = TempData["CategoryId"] });


Here,

Method Name is a function which is created in controller.

CategoryId must be a part of that parameter.

TempData["CategoryId"] because it is going to redirect the page. so Viewbag is not reliable to use.




Monday, 21 April 2014

Proportional Image Resize in C# .net


Proportional Image Resize in C# .net :

public static Bitmap CreateThumbnail(string lcFilename, int lnWidth, int lnHeight)
        {
            Bitmap bmpOut = null;

            try
            {
                var loBmp = new Bitmap(lcFilename);              
                var lnNewWidth = 0;
                var lnNewHeight = 0;

                if (loBmp.Height == loBmp.Width)
                {
                    lnNewWidth = lnNewHeight = lnHeight;
                }
                else if (loBmp.Height > loBmp.Width)
                {
                    lnNewHeight = lnHeight;
                    lnNewWidth = (loBmp.Width * lnWidth) / loBmp.Height;
                }
                else
                {
                    lnNewHeight = lnWidth;
                    lnNewWidth = (loBmp.Width * lnHeight) / loBmp.Height;

                    lnNewWidth = lnWidth;
                    lnNewHeight = (loBmp.Height * lnHeight) / loBmp.Width;
                }              

                bmpOut = new Bitmap(lnNewWidth, lnNewHeight);

                var g = Graphics.FromImage(bmpOut);
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                g.FillRectangle(Brushes.Transparent, 0, 0, lnNewWidth, lnNewHeight);
                g.DrawImage(loBmp, 0, 0, lnNewWidth, lnNewHeight);
                loBmp.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return bmpOut;
        }

Thursday, 9 January 2014

Facebook Sign In Button


<script language="javascript" type="text/javascript">
    // Load the SDK Asynchronously
    (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: '680827721940158', // Write your own application id
            channelUrl: '//' + window.location.hostname + '/channel', // Path to your Channel File
            scope: 'id,name,gender,user_birthday,email,user_location,user_hometown',
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true  // parse XFBML
            //,perms: 'user_address, user_mobile_phone'
        });
       

        // 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
                var uid = "http://graph.facebook.com/" + response.authResponse.userID + "/picture";
                FB.api('/me', function (me) {
                    if (me.name) {
                        //me.name
                        document.getElementById('<%= txtNewFirstName.ClientID%>').value = me.first_name;
                        document.getElementById('<%= txtNewLastName.ClientID%>').value = me.last_name;
                        document.getElementById('<%= txtNewEmail.ClientID%>').value = me.email;

                        var location = me.location.name.split(',');

                        //For Country DropDown
                        var isCountry = false;
                        $("#<%=ddlNewCountry.ClientID%> option[selected]").removeAttr("selected");
                        var textToFind = location[1].trim();

                       me.languages[0].name.trim();
                       // $("#<%=ddlNewCountry.ClientID%>").val(location[1].trim());
                        //me.birthday;
                        // uid;
                        //me.gender;
                    }
                })
                document.getElementById('auth-loggedout').style.display = 'block';
                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(); }); });
    }
</script>

Create account in
http://developers.facebook.com/
create new application and please the url in web login(where to use)
Make sure that sandbox is disable.

Google Plus Sign In Button



<html>
<head>
  <title>Demo: Getting an email address using the Google+ Sign-in button</title>
  <style type="text/css">
  html, body { margin: 0; padding: 0; }
  .hide { display: none;}
  .show { display: block;}
  </style>
  <script type="text/javascript">
      /**
      * Global variables to hold the profile and email data.
      */
      var profile, email;

      /*
      * Triggered when the user accepts the sign in, cancels, or closes the
      * authorization dialog.
      */
      function loginFinishedCallback(authResult) {
          if (authResult) {
              if (authResult['error'] == undefined) {
                  toggleElement('signin-button'); // Hide the sign-in button after successfully signing in the user.
                  gapi.client.load('plus', 'v1', loadProfile);  // Trigger request to get the email address.
              } else {
                  console.log('An error occurred');
              }
          } else {
              console.log('Empty authResult');  // Something went wrong
          }
      }

      /**
      * Uses the JavaScript API to request the user's profile, which includes
      * their basic information. When the plus.profile.emails.read scope is
      * requested, the response will also include the user's primary email address
      * and any other email addresses that the user made public.
      */
      function loadProfile() {
          var request = gapi.client.plus.people.get({ 'userId': 'me' });
          request.execute(loadProfileCallback);
      }

      /**
      * Callback for the asynchronous request to the people.get method. The profile
      * and email are set to global variables. Triggers the user's basic profile
      * to display when called.
      */
      function loadProfileCallback(obj) {
          profile = obj;
          console.log(obj);

          // Filter the emails object to find the user's primary account, which might
          // not always be the first in the array. The filter() method supports IE9+.
          email = obj['emails'].filter(function (v) {
              return v.type === 'account'; // Filter out the primary email
          })[0].value; // get the email from the filtered results, should always be defined.
          displayProfile(profile);
      }

      /**
      * Display the user's basic profile information from the profile object.
      */
      function displayProfile(profile) {
          document.getElementById('name').innerHTML = profile['displayName'];
          document.getElementById('name').innerHTML = profile['name']['givenName'] + " - " + profile['name']['familyName'];
          document.getElementById('pic').innerHTML = '<img src="' + profile['image']['url'] + '" />';
          document.getElementById('email').innerHTML = email;

          if (profile['language'] == 'en')
              document.getElementById('launguage').innerHTML = "English";
          else
              document.getElementById('launguage').innerHTML = "French";

          if (profile['placesLived'][0].value != "undefine");
          document.getElementById('PlacesLived').innerHTML = profile['placesLived'][0].value;
         
          toggleElement('profile');
      }

      /**
      * Utility function to show or hide elements by their IDs.
      */
      function toggleElement(id) {
          var el = document.getElementById(id);
          if (el.getAttribute('class') == 'hide') {
              el.setAttribute('class', 'show');
          } else {
              el.setAttribute('class', 'hide');
          }
      }
  </script>
  <script src="https://apis.google.com/js/client:plusone.js" type="text/javascript"></script>
</head>
<body>
  <div id="signin-button" class="show">
     <div class="g-signin"
      data-callback="loginFinishedCallback"
      data-approvalprompt="force"
      data-clientid="656942774761-v378l3ad6pm3q6k3s0hrfbd4dl4tq4te.apps.googleusercontent.com"
      data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read"
      data-height="short"
      data-cookiepolicy="single_host_origin"
      >
    </div>
    <!-- In most cases, you don't want to use approvalprompt=force. Specified
    here to facilitate the demo.-->
  </div>

  <div id="profile" class="hide">
    <div>
      <span id="pic"></span>
      <span id="name"></span>
    </div>

    <div id="email"></div>
    <div id="launguage"></div>
    <div id="PlacesLived"></div>
  </div>
</body>
</html>


Create Project with this Link

https://cloud.google.com/console/project

Then Follow the step

APIs & auth Tab -->  CredentialsClient ID for web applicationEdit Settings of (Redirect URIs & Javascript Origins)  Here write url of your site where to use.   

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()">