Monday, 18 March 2013

Add favriate

<div class="rightFavourite" id="addbtnDiv" runat="server">
    <a href="javascript:;" class="addFavourite" onclick="javascript:addToCompare();">Add to Favourite</a></div>
<asp:HiddenField ID="hdnPageUrl" runat="server" />
<asp:HiddenField ID="hdnPageTitle" runat="server" />
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class UserControls_UCaddFvrtBtn : System.Web.UI.UserControl
{
    FavouritePages.clFvrtPg objClFvrtPg = new FavouritePages.clFvrtPg();

    protected void Page_Load(object sender, EventArgs e)
    {
        hdnPageUrl.Value = HttpContext.Current.Request.Url.ToString();
        hdnPageTitle.Value = this.Page.Title.ToString();
        checkPageExits();
    }
    public void checkPageExits()
    {
        string pageUrl = HttpContext.Current.Request.Url.ToString();
        string pageTitle = this.Page.Title.ToString();

        DataTable _dtFvrtPg = objClFvrtPg.dtFavouritePages;
        if (_dtFvrtPg != null)
        {
            if (_dtFvrtPg.Rows.Count > 0)
            {
                foreach (DataRow dr in _dtFvrtPg.Rows)
                {
                    if (pageUrl == dr["PageUrl"].ToString() && pageTitle == dr["PageTitle"].ToString())
                    {
                        addbtnDiv.Attributes.Add("style", "display:none");
                    }                 
                }
            }
        }
    }
}

Tuesday, 5 March 2013

Request UrlReferrer

 if (Request.UrlReferrer == null)
            {
}


<script language="JavaScript" type="text/javascript">
    window.history.forward();
    function noBack() { window.history.forward(); }

    </script>

<body onload="noBack();" onpageshow="if (event.persisted) noBack();" onunload="">