protected override void AttachChildControls() { this.favorites = (Common_Favorite_ProductList)this.FindControl("list_Common_Favorite_ProList"); this.btnSearch = ButtonManager.Create(this.FindControl("btnSearch")); this.txtKeyWord = (TextBox)this.FindControl("txtKeyWord"); this.pager = (Pager)this.FindControl("pager"); this.btnDeleteSelect = (LinkButton)this.FindControl("btnDeleteSelect"); this.btnSearch.Click += new EventHandler(this.btnSearch_Click); this.favorites._ItemCommand += new Common_Favorite_ProductList.CommandEventHandler(this.favorites_ItemCommand); this.btnDeleteSelect.Click += new EventHandler(this.btnDeleteSelect_Click); PageTitle.AddSiteNameTitle("商品收藏夹", HiContext.Current.Context); if (!this.Page.IsPostBack) { if (!string.IsNullOrEmpty(this.Page.Request.QueryString["ProductId"])) { int result = 0; int.TryParse(this.Page.Request.QueryString["ProductId"], out result); if (!CommentsHelper.ExistsProduct(result) && !CommentsHelper.AddProductToFavorite(result)) { this.ShowMessage("添加商品到收藏夹失败", false); } } this.BindList(); } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productId"])) { int result = 0; int.TryParse(this.Page.Request.QueryString["productId"], out result); if (CommentsHelper.ExistsProduct(result)) { Response.Clear(); Response.Write("same"); Response.End(); } else if (!CommentsHelper.ExistsProduct(result) && !CommentsHelper.AddProductToFavorite(result)) { Response.Clear(); Response.Write("false"); Response.End(); } else { Response.Clear(); Response.Write("true"); Response.End(); } } }