Thursday, 21 July 2016

how to get disabled TextBox value in c#

how to get disabled TextBox value in c#

how to get disabled TextBox value in c#
Description:

In this example we explain that how to fetch value of disabled textbox in asp.net.or how to retrieving value of disabled Asp.Net textbox. Or how to get disabled textbox value in C#.

.net cannot get value from disabled or read-only textbox control so how to get new updated value of disabled textbox in asp.net in code behind.

For example suppose I have 3 textbox price, quantity and total. The value of the total textbox is disabled because of the total is automatically calculated based on the quantity and price.so when we update the quantity or price the total will be calculated proper but when we click on save button it will retrieve or fetch always its old or previous values because of the textbox disabled.so to overcome this problem we have to add one more HiddenField that will store the updated value of the disabled textbox(total textbox value) and when user click on save button at that time we have to insert HiddenField value so it will always save the latest or updated value of the disabled textbox.

how to get disabled TextBox value in c#

how to get disabled TextBox value in c#

how to get disabled TextBox value in c#

how to get disabled TextBox value in c#
Description:

In this example we explain that how to fetch value of disabled textbox in asp.net.or how to retrieving value of disabled Asp.Net textbox. Or how to get disabled textbox value in C#.

.net cannot get value from disabled or read-only textbox control so how to get new updated value of disabled textbox in asp.net in code behind.

For example suppose I have 3 textbox price, quantity and total. The value of the total textbox is disabled because of the total is automatically calculated based on the quantity and price.so when we update the quantity or price the total will be calculated proper but when we click on save button it will retrieve or fetch always its old or previous values because of the textbox disabled.so to overcome this problem we have to add one more HiddenField that will store the updated value of the disabled textbox(total textbox value) and when user click on save button at that time we have to insert HiddenField value so it will always save the latest or updated value of the disabled textbox.

Wednesday, 20 July 2016

swapping data

Description:

In this example we explain that how to Swap values between two columns using SQL Server query. Or how to update column1 values to column2 and column2 values to column1 like vice versa in sql server using update statement.

As we all know that when we working with database moving, swapping and updating values between a column is a common task for the all the developer in IT industries because there is a routine work.
Here in the below example we have one table called test in which there are two column column1 and column2 in which we have to swap the data column1 to column2 and vice versa.

How to Swap Values between Two Columns in SQL Server

swapping data

Description:

In this example we explain that how to Swap values between two columns using SQL Server query. Or how to update column1 values to column2 and column2 values to column1 like vice versa in sql server using update statement.

As we all know that when we working with database moving, swapping and updating values between a column is a common task for the all the developer in IT industries because there is a routine work.
Here in the below example we have one table called test in which there are two column column1 and column2 in which we have to swap the data column1 to column2 and vice versa.
This entry was posted in :
 how to access shared Network drive file using C#
Description:

In this example we explain that how to access shared Network drive file using C# code. Or how to access file from remote computer with providing credential or how to access server file that is hosted on another network with same domain. Or how to access file on another computer shared folder. Or access network file using asap.net.or how to provide user name and password when connecting to a network share in asp.net.

There are many question that how to use network file that is located in another computer. Below is the code that demonstrate that how to use the network file with login with credential in remote computer. First you have to create a NetworkShareAccesser class to validate the user with credential.

How to access shared Network drive file using C#

 how to access shared Network drive file using C#
Description:

In this example we explain that how to access shared Network drive file using C# code. Or how to access file from remote computer with providing credential or how to access server file that is hosted on another network with same domain. Or how to access file on another computer shared folder. Or access network file using asap.net.or how to provide user name and password when connecting to a network share in asp.net.

There are many question that how to use network file that is located in another computer. Below is the code that demonstrate that how to use the network file with login with credential in remote computer. First you have to create a NetworkShareAccesser class to validate the user with credential.

Monday, 18 July 2016

Add Row Click event to GridView Rows in ASP.Net

Add Row Click event to GridView Rows in ASP.Net
Description:

In this example we explain that how to add Row Click event in GridView in asp.net using C#.or how to add row click event to Gridview Rows in asp.net.

Sometime we have requirement like when user click on Gridview Row then it will display its related information on popup.

Here we demonstrate how to pass row index in the row click of the gridview and perform some operation.we used gridviews onSelectedIndexChanged event to perform the row click functionality of the gridview.

How to add click event to rows in Gridview in asp.net

Add Row Click event to GridView Rows in ASP.Net

Add Row Click event to GridView Rows in ASP.Net
Description:

In this example we explain that how to add Row Click event in GridView in asp.net using C#.or how to add row click event to Gridview Rows in asp.net.

Sometime we have requirement like when user click on Gridview Row then it will display its related information on popup.

Here we demonstrate how to pass row index in the row click of the gridview and perform some operation.we used gridviews onSelectedIndexChanged event to perform the row click functionality of the gridview.

Friday, 15 July 2016

scroll to first error


Description:

In this example we explain that how to set cursor to first error when validation raise error in asp.net.or scroll to the first error when error is raised in asp.net.

We all know that for the user point of view if our application have a long form at that time user will fill up the form and then last when he/she click on the submit button and if the validation is fired at that time user doesn’t have any idea which filled are missing or incorrect because of the long form.
So avoid this type of mistake and provide nice layout to the user for the end user satisfaction we have to direct scroll user to the first error raised by the validator so user can easily understand that and solved that.

So below is the code that demonstrate how to scroll to first validator error when validation failed in asp.net.

set cursor to first error when validation raise error in asp.net

scroll to first error


Description:

In this example we explain that how to set cursor to first error when validation raise error in asp.net.or scroll to the first error when error is raised in asp.net.

We all know that for the user point of view if our application have a long form at that time user will fill up the form and then last when he/she click on the submit button and if the validation is fired at that time user doesn’t have any idea which filled are missing or incorrect because of the long form.
So avoid this type of mistake and provide nice layout to the user for the end user satisfaction we have to direct scroll user to the first error raised by the validator so user can easily understand that and solved that.

So below is the code that demonstrate how to scroll to first validator error when validation failed in asp.net.
refresh a Grid View automatically at regular intervals
Description:

In this example we explain that how to refresh a Grid View automatically at regular intervals in asp.net.or refresh grid view after every 5 second in asp.net using C#.

Here we use we use Timer control to achieve this requirements. Simply we add the Grid view in the AJAX Update Panel control and set the timer interval in which we have to refresh the grid view automatically.

Below the code that demonstrate auto refresh grid view after specified interval in asp.net.

Auto Refresh Update GridView In Asp.Net Ajax With Timer.

refresh a Grid View automatically at regular intervals
Description:

In this example we explain that how to refresh a Grid View automatically at regular intervals in asp.net.or refresh grid view after every 5 second in asp.net using C#.

Here we use we use Timer control to achieve this requirements. Simply we add the Grid view in the AJAX Update Panel control and set the timer interval in which we have to refresh the grid view automatically.

Below the code that demonstrate auto refresh grid view after specified interval in asp.net.

Thursday, 14 July 2016

Server Side (Code Behind) Yes No Confirmation Message Box in ASP.Net

Description:

In this example we explain that how to display Confirmation box in server side in asp.net. Or display confirm box in code behind in c# in asp.net.or how to build a confirm message or dialog box at server side or code behind in asp.net.

In client side using JavaScript it is possible to create confirm box simply but how can I call on server side because JavaScript only post back when we click on “OK” but when we click on “Cancel” it will not post back. So how can I perform operation when click on OK or Cancel as per click.

Below is the example that demonstrate display confirm box when click on button and display message to the user you press ok button or cancel button at server side or code behind in asp.net.

display confirmbox code behind (server side) in asp.net

Server Side (Code Behind) Yes No Confirmation Message Box in ASP.Net

Description:

In this example we explain that how to display Confirmation box in server side in asp.net. Or display confirm box in code behind in c# in asp.net.or how to build a confirm message or dialog box at server side or code behind in asp.net.

In client side using JavaScript it is possible to create confirm box simply but how can I call on server side because JavaScript only post back when we click on “OK” but when we click on “Cancel” it will not post back. So how can I perform operation when click on OK or Cancel as per click.

Below is the example that demonstrate display confirm box when click on button and display message to the user you press ok button or cancel button at server side or code behind in asp.net.

Tuesday, 12 July 2016

group by with alias column name in SQL Server
Description:

In this example we explain that how to group by with alias column name in SQL Server query. Or group by on alias column in SQL Server. Or SQL Server example to Group by alias column name in SQL query.

Sometime we have requirement like required or fetch data in SQL Server but in alias column name. Below is the query that demonstrates the Group by data in SQL Server with alias column name.

SQL Server query to group by with alias column name .

group by with alias column name in SQL Server
Description:

In this example we explain that how to group by with alias column name in SQL Server query. Or group by on alias column in SQL Server. Or SQL Server example to Group by alias column name in SQL query.

Sometime we have requirement like required or fetch data in SQL Server but in alias column name. Below is the query that demonstrates the Group by data in SQL Server with alias column name.
This entry was posted in :

Thursday, 7 July 2016

Query to find all stored procedure containing <text>? In SQL Server
Description:

In this example we explain that how to find all Stored Procedure containing text. Or how do I find a stored procedure procedure contain a text. Search text in a stored procedure in SQL Server. Search string in a stored procedure. Find all procedure in SQL Server that contains a specified text. Find stored procedure by a string.

There are lots of question are arise in our mind when we would not know that how many procedure are used like we search.

Suppose we have requirement like find all the stored procedure in SQL Database which contain a particular text that may be a field name or any declare variable name or anything.

How do I find all stored procedure containing ? In SQL Server

Query to find all stored procedure containing <text>? In SQL Server
Description:

In this example we explain that how to find all Stored Procedure containing text. Or how do I find a stored procedure procedure contain a text. Search text in a stored procedure in SQL Server. Search string in a stored procedure. Find all procedure in SQL Server that contains a specified text. Find stored procedure by a string.

There are lots of question are arise in our mind when we would not know that how many procedure are used like we search.

Suppose we have requirement like find all the stored procedure in SQL Database which contain a particular text that may be a field name or any declare variable name or anything.

This entry was posted in :

Wednesday, 6 July 2016

JSON support in SQL Server 2016
Description:

In this example we explain that how to use JSON in SQL Server 2016.or how to use JSON in SQL Server or retrieve or fetch data from SQL Server in JSON format.

Till now it was tricky in sql to split or use Json , But SQL Server 2016 has provided Inbuilt functions for JSON support.

How to retrieve data from SQL Sever in JSON format.

JSON support in SQL Server 2016
Description:

In this example we explain that how to use JSON in SQL Server 2016.or how to use JSON in SQL Server or retrieve or fetch data from SQL Server in JSON format.

Till now it was tricky in sql to split or use Json , But SQL Server 2016 has provided Inbuilt functions for JSON support.

How to integrate citrus payment gateway in ASP.NET



Description:
  • generally online payment gateway flow as follows.
    • When customers are ready to pay, they enter their payment information and click the payment button on your website.
    • The payment gateway encrypts data and securely sends it through the payment processing network.
    • The transaction is reviewed for authorization or decline, and the results are sent back through the Payflow payment gateway.
    • Your customer receives a confirmation receipt and you fulfill the order.
    • Once the transaction is processed, funds are transferred from the customer’s bank account to your merchant bank account.



So now, how to integrate onsite citrus payment integration in asp.net with c#.
Pre requisites : 
    • Citrus Account
    • Vanity Url
    • ​Security creadentials 
​Login to sandbox (in case of Testing) or production (in case of Live) using the user ID and password received from Citruspay.

How to Get Vanity URL :

 After login to your citrus account and go to checkout page setting tab in right panel.


How to Get Security Credentials :




Payment Request Parameters : 

  Before go further please make sure your payment paramters as per below discription.



1. Create a sample request page to post a transaction request to citrus. (Refer PaymentRedirect.aspx Page.)
2. Create a sample response page to receive the response on your website.(Refer PaymentRespose.aspx page)

Once user click on Make payment button redirect them to ​PaymentRedirect.aspx with your session variables.

Create a sample request page to post a transaction request to citrus.
Page: PaymentRedirect.aspx

PaymentRedirect.aspx:
​​
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PaymentRedirect.aspx.cs"
    Inherits="PaymentRedirect" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Payment Redirect</title>   
    <script type="text/javascript">
        function myfunc() {
            var frm = document.all("formpayment");
            frm.submit();
        }
        window.onload = myfunc;
    </script>
</head>
<body>   
    <table class="divWaiting" width="100%">
        <tr>
            <td height="200px">
                 
            </td>
        </tr>
        <tr>
            <td align="center">
                <img alt="Processing" src="Images/updateprogress.gif" />
            </td>
        </tr>
        <tr>
            <td align="center"
                   style="color: black; font-family: Calibri; font-size: 22px;">
                Please wait while we are redirect you to payment gateway for precessing...
                <br />
                Please do not press <strong>Stop</strong>,
                   <strong>Back</strong> or <strong>Refresh</strong>
                button or <strong>Close</strong> this window."
            </td>
        </tr>
    </table>
    <form id="formpayment" method="post" action="<%=formPostUrl%>">
    <input type="hidden" id="merchantTxnId" name="merchantTxnId" value="<%=merchantTxnId%>" />
    <input type="hidden" id="orderAmount" name="orderAmount" value="<%=orderAmount%>" />
    <input type="hidden" id="currency" name="currency" value="<%=currency%>" />
    <input type="hidden" name="returnUrl" value="<%=returnUrl %>" />
    <input type="hidden" id="notifyUrl" name="notifyUrl" value="<%=notifyUrl%>" />
    <input type="hidden" id="secSignature" name="secSignature" value="<%=securitySignature%>" />
    </form>
</body>
</html>


​​​

PaymentRedirect.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.Configuration;
using System.Data;
using System.Net;
using System.Text;
using System.IO;


public partial class PaymentRedirect : System.Web.UI.Page
{
    LogErrorToLogFile logFile = new LogErrorToLogFile();

    protected string formPostUrl = "";
    protected string currency = "";
    protected string returnUrl = "";
    protected string notifyUrl = "";

    protected string merchantTxnId = "";
    protected string secret_key = "";
    protected string vanityUrl = "";
    protected string orderAmount = "0.00";
    protected string securitySignature = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
       //Get All Payment Related Details from Database server. or set details in
         web.config file.
            DataTable dtPaymentInformation = null;
            DevCommon.Select("SPSelectApplicationPaymentDetailByApplicationFormId",
        ref dtPaymentInformation, Convert.ToInt64(Session["ApplicationFormId"]));
            if (dtPaymentInformation != null && dtPaymentInformation.Rows.Count > 0)
            {
    
            currency = Convert.ToString(dtPaymentInformation.Rows[0]["currency"]);
            returnUrl = Convert.ToString(dtPaymentInformation.Rows[0]["returnUrl"]);
            notifyUrl = Convert.ToString(dtPaymentInformation.Rows[0]["notifyUrl"]);
           // Will provide unique for every request to citrus.    
            merchantTxnId = Convert.ToString(Session["TransactionReferenceNo"]); 
           
            secret_key = Convert.ToString(dtPaymentInformation.Rows[0]["secret_key"]);
            vanityUrl = Convert.ToString(dtPaymentInformation.Rows[0]["vanityUrl"]);
            formPostUrl = "https://www.citruspay.com/" + vanityUrl;
                
            orderAmount = Convert.ToString(dtPaymentInformation.Rows[0]["AdminCharges"]);
       // For testing we have set order amount 1 rupees.
            orderAmount = "1";
            }
            else
            {
                Response.Redirect("Default.aspx");
            }
            string data = vanityUrl + orderAmount + merchantTxnId + currency;

            System.Security.Cryptography.HMACSHA1 myhmacsha1 = new
       System.Security.Cryptography.HMACSHA1(Encoding.ASCII.GetBytes(secret_key));
            System.IO.MemoryStream stream = new
       System.IO.MemoryStream(Encoding.ASCII.GetBytes(data));
            securitySignature =
       BitConverter.ToString(myhmacsha1.ComputeHash(stream)).Replace("-", "").ToLower();

        }
        catch (Exception ex)
        {
            logFile.LogError(ex);
            return;
        }
    }
}
​​

Create a sample response page to receive the response on your website.

Create Page PaymentRespose.aspx and paste below code in .cs file.

PaymentRespose.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.Data;
using System.Configuration;

public partial class PaymentResponse : System.Web.UI.Page
{
    LogErrorToLogFile logFile = new LogErrorToLogFile();
    string txnId = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string data = "";
            txnId = Request["TxId"];
            string TxRefNo = Request["TxRefNo"];
            string txnStatus = Request["TxStatus"];
            string amount = Request["amount"];
            string TxMsg = Request["TxMsg"];           
            string pgTxnId = Request["pgTxnNo"];
            string issuerRefNo = Request["issuerRefNo"];
            string authIdCode = Request["authIdCode"];
            string firstName = Request["firstName"];
            string lastName = Request["lastName"];
            string pgRespCode = Request["pgRespCode"];
            string zipCode = Request["addressZip"];
            string resSignature = Request["signature"];
       
            bool flag = true;
            if (txnId != null)
            {
                data += txnId;
            }
            if (txnStatus != null)
            {
                data += txnStatus;
            }
            if (amount != null)
            {
                data += amount;
            }
            if (pgTxnId != null)
            {
                data += pgTxnId;
            }
            if (issuerRefNo != null)
            {
                data += issuerRefNo;
            }
            if (authIdCode != null)
            {
                data += authIdCode;
            }
            if (firstName != null)
            {
                data += firstName;
            }
            if (lastName != null)
            {
                data += lastName;
            }
            if (pgRespCode != null)
            {
                data += pgRespCode;
            }
            if (zipCode != null)
            {
                data += zipCode;
            }
      
            // Get a secret key from web.config or database server.
            //string secret_key = ConfigurationManager.AppSettings["secret_key"].ToString();

            DataTable dtPaymentInfo = null;
            string secret_key = "";
            DevCommon.Select("SPSelectApplicationPaymentDetailByTxId",
       ref dtPaymentInfo, Convert.ToString(txnId));
            if (dtPaymentInfo != null && dtPaymentInfo.Rows.Count > 0)
            {
                secret_key = Convert.ToString(dtPaymentInfo.Rows[0]["secret_key"]);
            }
            System.Security.Cryptography.HMACSHA1 myhmacsha1 = new
       System.Security.Cryptography.HMACSHA1(
            System.Text.Encoding.ASCII.GetBytes(secret_key));
            System.IO.MemoryStream stream = new
            System.IO.MemoryStream(System.Text.Encoding.ASCII.GetBytes(data));
            string signature =
       BitConverter.ToString(myhmacsha1.ComputeHash(stream)).Replace("-", "").ToLower();

            if (resSignature != null && !signature.Equals(resSignature))
            {
                flag = false;
            }

            if (flag)
            {
                DataTable datatable = null;
                object[] objPara = new object[14];
                objPara[0] = Convert.ToInt32(Session["ApplicationFormId"]);
                objPara[1] = txnId;
                objPara[2] = TxRefNo;
                objPara[3] = txnStatus;
                objPara[4] = amount;
                objPara[5] = TxMsg;
                objPara[6] = pgTxnId;
                objPara[7] = issuerRefNo;
                objPara[8] = authIdCode;
                objPara[9] = firstName;
                objPara[10] = lastName;
                objPara[11] = pgRespCode;
                objPara[12] = zipCode;
                objPara[13] = signature;
           

                   // Update transaction status in database and make sure your database
                   //amount and tansaction amount both are same while update transaction
                //status(eg. SUCCESS).
                DevCommon.InsertUpdate("SPUpdatePaymentDetails", ref datatable, objPara);
                if (datatable != null && datatable.Rows.Count > 0 &&
                   Convert.ToInt64(datatable.Rows[0][0]) > 0)
                {
                      // after successful update redirect to payment receipt for payment details.
                   //create payment reciept page as your requirement.
                    Response.Redirect("PaymentReceipt.aspx?txnId=" +
                       EncryptDecrypt.Encrypt(Convert.ToString(txnId), "P@ssw0rd"),false);
                }
            }
            else
            {
                Response.Redirect("default.aspx");
            }
        }
        catch (Exception ex)
        {
            // mail to Admin if fail to update status in database and redirect
       // to another page.           
            Response.Redirect("default.aspx");
        }

    }
}





How to integrate citrus payment gateway in ASP.NET


How to integrate citrus payment gateway in ASP.NET



Description:
  • generally online payment gateway flow as follows.
    • When customers are ready to pay, they enter their payment information and click the payment button on your website.
    • The payment gateway encrypts data and securely sends it through the payment processing network.
    • The transaction is reviewed for authorization or decline, and the results are sent back through the Payflow payment gateway.
    • Your customer receives a confirmation receipt and you fulfill the order.
    • Once the transaction is processed, funds are transferred from the customer’s bank account to your merchant bank account.



So now, how to integrate onsite citrus payment integration in asp.net with c#.
Pre requisites : 
    • Citrus Account
    • Vanity Url
    • ​Security creadentials 
​Login to sandbox (in case of Testing) or production (in case of Live) using the user ID and password received from Citruspay.

How to Get Vanity URL :

 After login to your citrus account and go to checkout page setting tab in right panel.


How to Get Security Credentials :




Payment Request Parameters : 

  Before go further please make sure your payment paramters as per below discription.



1. Create a sample request page to post a transaction request to citrus. (Refer PaymentRedirect.aspx Page.)
2. Create a sample response page to receive the response on your website.(Refer PaymentRespose.aspx page)

Once user click on Make payment button redirect them to ​PaymentRedirect.aspx with your session variables.

Create a sample request page to post a transaction request to citrus.
Page: PaymentRedirect.aspx

PaymentRedirect.aspx:
​​
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PaymentRedirect.aspx.cs"
    Inherits="PaymentRedirect" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Payment Redirect</title>   
    <script type="text/javascript">
        function myfunc() {
            var frm = document.all("formpayment");
            frm.submit();
        }
        window.onload = myfunc;
    </script>
</head>
<body>   
    <table class="divWaiting" width="100%">
        <tr>
            <td height="200px">
                 
            </td>
        </tr>
        <tr>
            <td align="center">
                <img alt="Processing" src="Images/updateprogress.gif" />
            </td>
        </tr>
        <tr>
            <td align="center"
                   style="color: black; font-family: Calibri; font-size: 22px;">
                Please wait while we are redirect you to payment gateway for precessing...
                <br />
                Please do not press <strong>Stop</strong>,
                   <strong>Back</strong> or <strong>Refresh</strong>
                button or <strong>Close</strong> this window."
            </td>
        </tr>
    </table>
    <form id="formpayment" method="post" action="<%=formPostUrl%>">
    <input type="hidden" id="merchantTxnId" name="merchantTxnId" value="<%=merchantTxnId%>" />
    <input type="hidden" id="orderAmount" name="orderAmount" value="<%=orderAmount%>" />
    <input type="hidden" id="currency" name="currency" value="<%=currency%>" />
    <input type="hidden" name="returnUrl" value="<%=returnUrl %>" />
    <input type="hidden" id="notifyUrl" name="notifyUrl" value="<%=notifyUrl%>" />
    <input type="hidden" id="secSignature" name="secSignature" value="<%=securitySignature%>" />
    </form>
</body>
</html>


​​​

PaymentRedirect.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.Configuration;
using System.Data;
using System.Net;
using System.Text;
using System.IO;


public partial class PaymentRedirect : System.Web.UI.Page
{
    LogErrorToLogFile logFile = new LogErrorToLogFile();

    protected string formPostUrl = "";
    protected string currency = "";
    protected string returnUrl = "";
    protected string notifyUrl = "";

    protected string merchantTxnId = "";
    protected string secret_key = "";
    protected string vanityUrl = "";
    protected string orderAmount = "0.00";
    protected string securitySignature = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
       //Get All Payment Related Details from Database server. or set details in
         web.config file.
            DataTable dtPaymentInformation = null;
            DevCommon.Select("SPSelectApplicationPaymentDetailByApplicationFormId",
        ref dtPaymentInformation, Convert.ToInt64(Session["ApplicationFormId"]));
            if (dtPaymentInformation != null && dtPaymentInformation.Rows.Count > 0)
            {
    
            currency = Convert.ToString(dtPaymentInformation.Rows[0]["currency"]);
            returnUrl = Convert.ToString(dtPaymentInformation.Rows[0]["returnUrl"]);
            notifyUrl = Convert.ToString(dtPaymentInformation.Rows[0]["notifyUrl"]);
           // Will provide unique for every request to citrus.    
            merchantTxnId = Convert.ToString(Session["TransactionReferenceNo"]); 
           
            secret_key = Convert.ToString(dtPaymentInformation.Rows[0]["secret_key"]);
            vanityUrl = Convert.ToString(dtPaymentInformation.Rows[0]["vanityUrl"]);
            formPostUrl = "https://www.citruspay.com/" + vanityUrl;
                
            orderAmount = Convert.ToString(dtPaymentInformation.Rows[0]["AdminCharges"]);
       // For testing we have set order amount 1 rupees.
            orderAmount = "1";
            }
            else
            {
                Response.Redirect("Default.aspx");
            }
            string data = vanityUrl + orderAmount + merchantTxnId + currency;

            System.Security.Cryptography.HMACSHA1 myhmacsha1 = new
       System.Security.Cryptography.HMACSHA1(Encoding.ASCII.GetBytes(secret_key));
            System.IO.MemoryStream stream = new
       System.IO.MemoryStream(Encoding.ASCII.GetBytes(data));
            securitySignature =
       BitConverter.ToString(myhmacsha1.ComputeHash(stream)).Replace("-", "").ToLower();

        }
        catch (Exception ex)
        {
            logFile.LogError(ex);
            return;
        }
    }
}
​​

Create a sample response page to receive the response on your website.

Create Page PaymentRespose.aspx and paste below code in .cs file.

PaymentRespose.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.Data;
using System.Configuration;

public partial class PaymentResponse : System.Web.UI.Page
{
    LogErrorToLogFile logFile = new LogErrorToLogFile();
    string txnId = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string data = "";
            txnId = Request["TxId"];
            string TxRefNo = Request["TxRefNo"];
            string txnStatus = Request["TxStatus"];
            string amount = Request["amount"];
            string TxMsg = Request["TxMsg"];           
            string pgTxnId = Request["pgTxnNo"];
            string issuerRefNo = Request["issuerRefNo"];
            string authIdCode = Request["authIdCode"];
            string firstName = Request["firstName"];
            string lastName = Request["lastName"];
            string pgRespCode = Request["pgRespCode"];
            string zipCode = Request["addressZip"];
            string resSignature = Request["signature"];
       
            bool flag = true;
            if (txnId != null)
            {
                data += txnId;
            }
            if (txnStatus != null)
            {
                data += txnStatus;
            }
            if (amount != null)
            {
                data += amount;
            }
            if (pgTxnId != null)
            {
                data += pgTxnId;
            }
            if (issuerRefNo != null)
            {
                data += issuerRefNo;
            }
            if (authIdCode != null)
            {
                data += authIdCode;
            }
            if (firstName != null)
            {
                data += firstName;
            }
            if (lastName != null)
            {
                data += lastName;
            }
            if (pgRespCode != null)
            {
                data += pgRespCode;
            }
            if (zipCode != null)
            {
                data += zipCode;
            }
      
            // Get a secret key from web.config or database server.
            //string secret_key = ConfigurationManager.AppSettings["secret_key"].ToString();

            DataTable dtPaymentInfo = null;
            string secret_key = "";
            DevCommon.Select("SPSelectApplicationPaymentDetailByTxId",
       ref dtPaymentInfo, Convert.ToString(txnId));
            if (dtPaymentInfo != null && dtPaymentInfo.Rows.Count > 0)
            {
                secret_key = Convert.ToString(dtPaymentInfo.Rows[0]["secret_key"]);
            }
            System.Security.Cryptography.HMACSHA1 myhmacsha1 = new
       System.Security.Cryptography.HMACSHA1(
            System.Text.Encoding.ASCII.GetBytes(secret_key));
            System.IO.MemoryStream stream = new
            System.IO.MemoryStream(System.Text.Encoding.ASCII.GetBytes(data));
            string signature =
       BitConverter.ToString(myhmacsha1.ComputeHash(stream)).Replace("-", "").ToLower();

            if (resSignature != null && !signature.Equals(resSignature))
            {
                flag = false;
            }

            if (flag)
            {
                DataTable datatable = null;
                object[] objPara = new object[14];
                objPara[0] = Convert.ToInt32(Session["ApplicationFormId"]);
                objPara[1] = txnId;
                objPara[2] = TxRefNo;
                objPara[3] = txnStatus;
                objPara[4] = amount;
                objPara[5] = TxMsg;
                objPara[6] = pgTxnId;
                objPara[7] = issuerRefNo;
                objPara[8] = authIdCode;
                objPara[9] = firstName;
                objPara[10] = lastName;
                objPara[11] = pgRespCode;
                objPara[12] = zipCode;
                objPara[13] = signature;
           

                   // Update transaction status in database and make sure your database
                   //amount and tansaction amount both are same while update transaction
                //status(eg. SUCCESS).
                DevCommon.InsertUpdate("SPUpdatePaymentDetails", ref datatable, objPara);
                if (datatable != null && datatable.Rows.Count > 0 &&
                   Convert.ToInt64(datatable.Rows[0][0]) > 0)
                {
                      // after successful update redirect to payment receipt for payment details.
                   //create payment reciept page as your requirement.
                    Response.Redirect("PaymentReceipt.aspx?txnId=" +
                       EncryptDecrypt.Encrypt(Convert.ToString(txnId), "P@ssw0rd"),false);
                }
            }
            else
            {
                Response.Redirect("default.aspx");
            }
        }
        catch (Exception ex)
        {
            // mail to Admin if fail to update status in database and redirect
       // to another page.           
            Response.Redirect("default.aspx");
        }

    }
}