protected void Page_Load(object sender, EventArgs e)
    {
        string adID      = Utility.GetParameter("id");
        string pageName  = Utility.GetParameter("pn");
        string placement = Utility.GetParameter("pl");

        ViewState.Add("pageName", pageName);
        ViewState.Add("placement", placement);
        btnDelete.Visible = false;
        if (!Page.IsPostBack)
        {
            LoadProducts();
            LoadCategories();
        }
        if (adID != string.Empty)
        {
            btnDelete.Visible = true;
            btnDelete.Attributes.Add("onclick", "return CheckDelete();");
            ViewState.Add("adID", adID);
            if (!Page.IsPostBack)
            {
                Commerce.Common.Ad ad = new Commerce.Common.Ad(int.Parse(adID));
                txtAdText.Text = ad.AdText;

                ddlCategoryID.SelectedValue = ad.CategoryID.ToString();
                ddlProductID.SelectedValue  = ad.ProductSku;
            }
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Commerce.Common.Ad ad = null;;

        if (ViewState["adID"] != null)
        {
            int adID = int.Parse(ViewState["adID"].ToString());
            ad = new Commerce.Common.Ad(adID);
        }
        else
        {
            ad = new Commerce.Common.Ad();
        }
        ad.AdText      = txtAdText.Text;
        ad.CategoryID  = int.Parse(ddlCategoryID.Text);
        ad.DateExpires = DateTime.UtcNow.AddDays(100);
        ad.PageName    = ViewState["pageName"].ToString();
        ad.Placement   = ViewState["placement"].ToString();
        ad.ProductSku  = ddlProductID.Text;
        ad.Save(Utility.GetUserName());

        ResultMessage1.ShowSuccess("Ad Saved");
    }