Pankaj Tahiliani

  Home  |   Contact  |   Syndication    |   Login
  34 Posts | 0 Stories | 51 Comments | 0 Trackbacks

News

Twitter












Archives

Post Categories

Friday, January 3, 2014 #

Delete/Rebuild umbraco based website cache from direct url:
http://<<yourdomain.com>>/Umbraco/dialogs/republish.aspx?xml=true

Friday, August 30, 2013 #

Problem: MethodAccessException: Attempt by method 'DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure)' to access method 'System.Web.UI.Control.get_ViewState()' failed

Possible Solution: Add the below line in web.config under <system.web> tag
<trust level="Full"/>


Friday, August 23, 2013 #

<html>
<head>
    <title>Facebook Login Authentication Example</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
    <script>
        // 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: '<<<ENTER YOUR FACEBOOK APP ID HERE>>>', // 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;
                        }
                        if (me.id) {
                            document.getElementById('FBId').innerHTML = me.id;
                            document.getElementById('Pic').src = 'http://graph.facebook.com/' + me.id + '/Picture';
                            document.getElementById('Pic').alt = me.name;
                            document.getElementById('Pic').title = me.name;
                        }

                        if (me.email) {
                            document.getElementById("DisplayEmail").innerHTML = me.email;
                        }
                        if (me.gender) {
                            document.getElementById("Gender").innerHTML = me.gender;
                        }
                        if (me.birthday) {
                            document.getElementById("DOB").innerHTML = me.birthday;
                        }

                    })
                    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(); }); });
        }
    </script>
    <h1>Facebook Login Authentication Example</h1>
    <div id="auth-status">
        <div id="auth-loggedout">
            <div class="fb-login-button" autologoutlink="true" scope="email,user_checkins">Login  with Facebook</div>
        </div>
        <div id="auth-loggedin" style="display: none">
            Hi, <span id="auth-displayname"></span>(<a href="#" id="auth-logoutlink">logout</a>)
            <br />
            Your Facebook ID : <span id="FBId"></span>
            <br />

            Your Email : <span id="DisplayEmail"></span>
            <br />

            Your Sex: <span id="Gender"></span>
            <br />

            Your Date of Birth: <span id="DOB"></span>
            <br />

            Your Pic:
            <img id="Pic" />
            <br />
        </div>
    </div>
</body>
</html>

Saturday, July 20, 2013 #

DATENAME function is used to get string of the specified datepart of the specified date.

DATEPART Return of the specified date an integer that represents a specific date

Consider a problem where we have to converting a date to display in the MON YYYY format where "MON" is the 3 character month such as "Jan", "Feb", "Mar", etc.

use NORTHWIND;

SELECT CASE DATEPART(mm,OrderDate) 
             WHEN 01 THEN 'Jan'
             WHEN 02 THEN 'Feb'
             WHEN 03 THEN 'Mar'
             WHEN 04 THEN 'Apr'
             WHEN 05 THEN 'May'
             WHEN 06 THEN 'Jun'
             WHEN 07 THEN 'Jul'
             WHEN 08 THEN 'Aug'
             WHEN 09 THEN 'Sep'
             WHEN 10 THEN 'Oct'
             WHEN 11 THEN 'Nov'
             ELSE 'Dec'
        END + ' ' + CAST(DATEPART(yy,OrderDate) AS CHAR(4))
   FROM Orders

In this example we have cast the results of datepart into character so that we can concatenate both the field results.

Now, in the below example you will see how fast is Datename function in comparison with  Datepart. 

USE NORTHWIND
DECLARE @Lorem CHAR(4);

PRINT '========== Original Method of Conversion ==========';
SET STATISTICS TIME ON;
SELECT @Lorem = CAST(DATEPART(yy,OrderDate) AS CHAR(4)) FROM Orders;
SET STATISTICS TIME OFF;

PRINT '========== DATENAME Method of Conversion ==========';
SET STATISTICS TIME ON;
SELECT @Lorem = DATENAME(yy,OrderDate) FROM Orders
SET STATISTICS TIME OFF; 


That gives us the following statistical output:

========== Original Method of Conversion ==========

SQL Server Execution Times:
CPU time = 1203 ms, elapsed time = 1 ms.
========== DATENAME Method of Conversion ==========

SQL Server Execution Times:
CPU time = 1156 ms, elapsed time = 0 ms.



DATENAME() has a rather special effect on days of the week and months. Instead of returning the numeric equivalent as a 2 character NVARCHAR, it actually spells the name out. Try it...
SELECT DATENAME(dw,GETDATE()), DATENAME(mm,GETDATE());


Wednesday, June 12, 2013 #

<html>
<head>
    <style type="text/css">
        .foo
        {
            counter-reset: foo;
        }
        .foo li
        {
            list-style-type: none;
        }
        .foo li::before
        {
            counter-increment: foo;
            content: "2." counter(foo) " ";
        }
    </style>
</head>
<body>
    <ol class="foo">
        <li>Lorem Lipsum</li>
        <li>Lorem Lipsum</li>
        <li>Lorem Lipsum</li>
        <li>Lorem Lipsum</li>
    </ol>
</body>
</html>

Thursday, October 25, 2012 #

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

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //API Credentials (3-token)
        string strUsername = "<<enter your sandbox username here>>";
        string strPassword = "<<enter your sandbox password here>>";
        string strSignature = "<<enter your signature here>>";
        string strCredentials = "USER=" + strUsername + "&PWD=" + strPassword + "&SIGNATURE=" + strSignature;

        string strNVPSandboxServer = "https://api-3t.sandbox.paypal.com/nvp";
        string strAPIVersion = "2.3";

        string strNVP = strCredentials + "&METHOD=DoDirectPayment" +
        "&CREDITCARDTYPE=" + "Visa" +
        "&ACCT=" + "4710496235600346" +
        "&EXPDATE=" + "10" + "2017" +
        "&CVV2=" + "123" +
        "&AMT=" + "12.34" +
        "&FIRSTNAME=" + "Demo" +
        "&LASTNAME=" + "User" +
        "&IPADDRESS=192.168.2.236" +
        "&STREET=" + "Lorem-1" +
        "&CITY=" + "Lipsum-1" +
        "&STATE=" + "Lorem" +
        "&COUNTRY=" + "INDIA" +
        "&ZIP=" + "302004" +
        "&COUNTRYCODE=IN" +
        "&PAYMENTACTION=Sale" +
        "&VERSION=" + strAPIVersion;

        try
        {
            //Create web request and web response objects, make sure you using the correct server (sandbox/live)
            HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(strNVPSandboxServer);
            wrWebRequest.Method = "POST";
            StreamWriter requestWriter = new StreamWriter(wrWebRequest.GetRequestStream());
            requestWriter.Write(strNVP);
            requestWriter.Close();

            // Get the response.
            HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();
            StreamReader responseReader = new StreamReader(wrWebRequest.GetResponse().GetResponseStream());

            //and read the response
            string responseData = responseReader.ReadToEnd();
            responseReader.Close();

            string result = Server.UrlDecode(responseData);

            string[] arrResult = result.Split('&');
            Hashtable htResponse = new Hashtable();
            string[] responseItemArray;
            foreach (string responseItem in arrResult)
            {
                responseItemArray = responseItem.Split('=');
                htResponse.Add(responseItemArray[0], responseItemArray[1]);
            }

            string strAck = htResponse["ACK"].ToString();

            if (strAck == "Success" || strAck == "SuccessWithWarning")
            {
                string strAmt = htResponse["AMT"].ToString();
                string strCcy = htResponse["CURRENCYCODE"].ToString();
                string strTransactionID = htResponse["TRANSACTIONID"].ToString();
                //ordersDataSource.InsertParameters["TransactionID"].DefaultValue = strTransactionID;

                string strSuccess = "Thank you, your order for: $" + strAmt + " " + strCcy + " has been processed.";
                //successLabel.Text = strSuccess;
                Response.Write(strSuccess.ToString());
            }
            else
            {
                string strErr = "Error: " + htResponse["L_LONGMESSAGE0"].ToString();
                string strErrcode = "Error code: " + htResponse["L_ERRORCODE0"].ToString();
                //errLabel.Text = strErr;
                //errcodeLabel.Text = strErrcode;
                Response.Write(strErr.ToString() + "<br/>" + strErrcode.ToString());
                return;
            }
        }
        catch (Exception ex)
        {
            // do something to catch the error, like write to a log file.
            Response.Write("error processing");
        }
    }
}

Sunday, May 29, 2011 #

Problem: When I try to bring up Outlook it has just begun giving me the following error message "Cannot start Microsoft Outlook. Invalid XML, the view cannot be load.

Solution: Start-> Run; outlook.exe /resetnavpane


Thursday, May 26, 2011 #

You dont need to make any changes to IIS7 to get url rewriter working properly. You just need to properly declare the module in web.config. Make sure you have the following in your web.config file:

<system.webServer>
 <modules runAllManagedModulesForAllRequests="true">
  <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
 </modules>
 <validation validateIntegratedModeConfiguration="false" />
</system.webServer>


Friday, May 20, 2011 #

Write this line in web.config file (for IIS 7)

<system.webserver>
<validation validateintegratedmodeconfiguration="false">
</validation>


Sunday, May 23, 2010 #

I got the above errror when I tried to run WSS default site after installing and running the Advance System Optimizer 3.o. I resolve this by going to the following locations and adding permission for the admin users accounts (ASP.NET & IIS_WPG) I have set up for Sharepoint.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
C:\WINDOWS\System 32\Log Files
C:\WINDOWS\Temp

After the correct permissions have been added, Sharepoint works as normal.