这是后台的代码,请大家帮我看看
-----------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class BackGround_GetProducts_Admin : System.Web.UI.Page
{
    BProducts product = new BProducts();
    DProducts dPoduct = new DProducts();    int sum = 1;//默认的总页数
    int pagesize = 5;//每页显示的记录数    protected void Page_Load(object sender, EventArgs e)
    {
        //获得总页数
        sum = product.GetPageSum(pagesize, 0);
        if (!Page.IsPostBack)
        {
            int page = 1;
            if (Request.QueryString["pages"] != null)
            {
                page = int.Parse(Request.QueryString["pages"].ToString());
            }            //显示新闻信息
            rptGetInfo_Bind(page);
            //显示可以跳转的页码
            ShowPageSize();        }
    }    /// <summary>
    ///  得到新闻数据
    /// </summary>
    protected void rptGetInfo_Bind(int page)
    {
        rptGetInfo.DataSource = product.GetPageMessage(pagesize, page);
        rptGetInfo.DataBind();
        TextSub();        lbAllPages.Text = sum.ToString();
        lbNowPage.Text = page.ToString();        if (sum == 0)
        {
            lbAllPages.Text = "1";
            lbNowPage.Text = "1";
            lbtnStartPage.Enabled = false;
            lbtnBeforePage.Enabled = false;
            lbtnAfterPage.Enabled = false;
            lbtnLastPage.Enabled = false;
            return;
        }        if (sum == 1)
        {
            lbtnStartPage.Enabled = false;
            lbtnBeforePage.Enabled = false;
            lbtnAfterPage.Enabled = false;
            lbtnLastPage.Enabled = false;
        }
        else if (page == sum)
        {
            lbtnStartPage.Enabled = true;
            lbtnBeforePage.Enabled = true;
            lbtnAfterPage.Enabled = false;
            lbtnLastPage.Enabled = false;
        }
        else if (page == 1)
        {
            lbNowPage.Text = page.ToString();
            lbtnStartPage.Enabled = false;
            lbtnBeforePage.Enabled = false;
            lbtnAfterPage.Enabled = true;
            lbtnLastPage.Enabled = true;
        }
        else
        {
            lbtnStartPage.Enabled = true;
            lbtnBeforePage.Enabled = true;
            lbtnAfterPage.Enabled = true;
            lbtnLastPage.Enabled = true;
        }
    }    /// <summary>
    /// 首页
    /// </summary>
    protected void lbtnStartPage_Click(object sender, EventArgs e)
    {
        int Page = 1;
        rptGetInfo_Bind(Page);
        lbNowPage.Text = Page.ToString();
        rptGetInfo.DataBind();
        TextSub();
    }    /// <summary>
    /// 上一页
    /// </summary>
    protected void lbtnBeforePage_Click(object sender, EventArgs e)
    {
        int Page = int.Parse(lbNowPage.Text);
        if (Page > 1)
        {
            Page--;
            rptGetInfo_Bind(Page);
            lbNowPage.Text = Page.ToString();
        }
        rptGetInfo.DataBind();
        TextSub();
    }    /// <summary>
    /// 下一页
    /// </summary>
    protected void lbtnAfterPage_Click(object sender, EventArgs e)
    {
        int Page = int.Parse(lbNowPage.Text);
        if (Page < sum)
        {
            Page++;
            if (Page == sum)
            {
                lbNowPage.Text = Page.ToString();
                rptGetInfo.DataSource = product.GetLastPageMessage(product.GetPageSum(pagesize, 1), pagesize, sum);
                rptGetInfo.DataBind();
                TextSub();
                lbtnStartPage.Enabled = true;
                lbtnBeforePage.Enabled = true;
                lbtnLastPage.Enabled = false;
                lbtnAfterPage.Enabled = false;
            }
            else
            {
                rptGetInfo_Bind(Page);
                lbNowPage.Text = Page.ToString();
                rptGetInfo.DataBind();
                TextSub();
            }
        }
    }    /// <summary>
    /// 尾页
    /// </summary>
    protected void lbtnLastPage_Click(object sender, EventArgs e)
    {
        int Page = int.Parse(lbNowPage.Text);
        Page = sum;
        lbNowPage.Text = Page.ToString();
        rptGetInfo.DataSource = product.GetLastPageMessage(product.GetPageSum(pagesize, 1), pagesize, sum);
        rptGetInfo.DataBind();
        TextSub();
        lbtnStartPage.Enabled = true;
        lbtnBeforePage.Enabled = true;
        lbtnLastPage.Enabled = false;
        lbtnAfterPage.Enabled = false;
    }    /// <summary>
    /// GO按钮
    /// </summary>
    protected void btnGoPage_Click(object sender, EventArgs e)
    {
        int page = int.Parse(dplJumpPage.SelectedValue);
        if (page == sum)
        {
            rptGetInfo.DataSource = product.GetLastPageMessage(product.GetPageSum(pagesize, 1), pagesize, sum);
            rptGetInfo.DataBind();
            TextSub();
            lbtnStartPage.Enabled = true;
            lbtnBeforePage.Enabled = true;
            lbtnLastPage.Enabled = false;
            lbtnAfterPage.Enabled = false;        }
        else
        {
            rptGetInfo_Bind(page);
            rptGetInfo.DataBind();
            TextSub();
        }
        lbNowPage.Text = dplJumpPage.SelectedValue;
    }    /// <summary>
    /// 显示页面数
    /// </summary>
    protected void ShowPageSize()
    {
        for (int i = 1; i <= sum; i++)
        {
            dplJumpPage.Items.Add(i.ToString());
        }
    }
    
    /// <summary>
    /// Repeater的数据绑定后触发
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void rptGetInfo_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Button lbtnTuiJian = e.Item.FindControl("lbtnTuiJian") as Button;
            LinkButton lbtnDelete = e.Item.FindControl("lbtnDelete") as LinkButton;
            if (e.CommandName == "del")
            {
                if (dPoduct.DeleteProductForId(DeleteProductId))
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"删除成功!\")</script>");
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"删除失败! 请重新操作\")</script>");
                }
            }
            else if (e.CommandName == "tuijian")
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + (e.Item.FindControl("lbTuiJian") as Label).Text + "')</script>");
            }
            Response.Redirect(Request.RawUrl);
            rptGetInfo_Bind(int.Parse(lbNowPage.Text));
        }
    }    /// <summary>
    /// 设置新闻内容或标题显示字符串长度
    /// </summary>
    protected void TextSub()
    {
        for (int i = 0; i < rptGetInfo.Items.Count; i++)
        {
            Label lbPName = (Label)rptGetInfo.Items[i].FindControl("lbPName");//商品所属
            Label lbTuiJian = (Label)rptGetInfo.Items[i].FindControl("lbTuiJian");
            switch (lbTuiJian.Text)
            {
                case "1":
                    lbTuiJian.Text = "推荐";
                    lbTuiJian.Attributes.Add("style", "color:red");
                    break;
                case "2":
                    lbTuiJian.Text = "不推荐";
                    lbTuiJian.Attributes.Add("style", "color:black");
                    break;
            }            switch (int.Parse(lbPName.Text))
            {
                case 1:
                    lbPName.Text = "清洁用品";
                    break;
                case 2:
                    lbPName.Text = "清洁工具";
                    break;
                case 3:
                    lbPName.Text = "家居生活";
                    break;
                case 4:
                    lbPName.Text = "母婴用品";
                    break;
                case 5:
                    lbPName.Text = "美容护肤";
                    break;
                case 6:
                    lbPName.Text = "服装服饰";
                    break;
            }
        }
    }
}

解决方案 »

  1.   

    这是前台代码:
    ---------------------------
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="GetProducts_Admin.aspx.cs" Inherits="BackGround_GetProducts_Admin" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><link href="css/ht_css.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <body>
    <form id="Form1" runat="server">
    <table width="100%" height="660" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="17" valign="top" background="images/mail_leftbg.gif" style="height: 49px"><img src="images/left-top-right.gif" width="17" height="29" /></td>
        <td valign="top" background="images/content-bg.gif" ><div class="titlebt"><p>&nbsp;</p>
            <ul>
             <li>查看商品</li>
            </ul></div></td>
        <td width="16" valign="top" background="images/mail_rightbg.gif" style="height: 49px"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
      </tr>
      <tr>
        <td valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
        <td height="590" valign="top" bgcolor="#F7F8F9">
        <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td class="left_txt">当前位置:查看商品</td>
              </tr>
              <tr>
                <td height="20"><table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
                  <tr>
                    <td></td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td><table width="100%" height="55" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="10%" height="55" valign="middle"><img src="images/title.gif" width="54" height="55"></td>
                    <td width="90%" valign="top"><span class="left_txt2">在这里,您可以查看您的网站商品<br />&nbsp;&nbsp;修改设置网站内的商品信息</span>
                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td style="height: 18px">&nbsp;</td>
              </tr>
              <tr>
                <td style="height: 49px">
                <table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                  <tr>
                    <td class="left_bt2" colspan="6">&nbsp;&nbsp;&nbsp;&nbsp;商品数据</td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="30"  align="left" bgcolor="#f2f2f2" class="left_txt2" colspan="4"><b>商品贷号</b></td>
                    <td height="30"  align="left" bgcolor="#f2f2f2" class="left_txt2" colspan="4"><b>商品图片</b></td>
                    <td height="30"  align="left" bgcolor="#f2f2f2" class="left_txt2" colspan="4"><b>商品名称</b></td>
                    <td height="30"  align="left" bgcolor="#f2f2f2" class="left_txt2" colspan="4"><b>商品所属</b></td>
                    <td height="30"  align="left" bgcolor="#f2f2f2" class="left_txt2" colspan="4"><b>商城价</b></td>
                    <td height="30"  align="left" bgcolor="#f2f2f2" class="left_txt2" colspan="4"><b>会员价</b></td>
                    <td height="30"  align="left" bgcolor="#f2f2f2" class="left_txt2" colspan="4"><b>浏览次数</b></td>
                    <td height="30"  align="left" bgcolor="#f2f2f2" class="left_txt2" colspan="4"><b>库存</b></td>
                    <td height="30"  align="left" bgcolor="#f2f2f2" class="left_txt2" colspan="4"><b>发布时间</b></td>
                    <td height="30"  align="left" bgcolor="#f2f2f2" class="left_txt2" colspan="4"><b>是否推荐</b></td>
                    <td height="30"  align="left" bgcolor="#f2f2f2" class="left_txt2" colspan="4"><b>操作</b></td>
                  </tr>
                    <asp:Repeater ID="rptGetInfo" runat="server" OnItemCommand="rptGetInfo_ItemCommand">
                        <ItemTemplate>
                            <tr>
                                <td height="30"   align="left" class="left_txt2" colspan="4"><%# Eval("productnumber")%></td>
                                <td height="30"   align="left" class="left_txt2" colspan="4"><img src='../<%# Eval("images") %>' alt='<%# Eval("productname")%>' width="50" height="50" /></td>
                                <td height="30"   align="left" class="left_txt2" colspan="4"><%# Eval("productname")%></td>
                                <td height="30"   align="left" class="left_txt2" colspan="4">
                                    <asp:Label ID="lbPName" runat="server" Text='<%# Eval("pid") %>'></asp:Label>
                                </td>
                                <td height="30"  align="left" class="left_txt2" colspan="4"><%# Eval("myPrice", "{0:¥0.00}")%></td>
                                <td height="30"  align="left" class="left_txt2" colspan="4"><%# Eval("VIPprice", "{0:¥0.00}")%></td>
                                <td height="30"  align="left" class="left_txt2" colspan="4"><%# Eval("look") %></td>
                                <td height="30"  align="left" class="left_txt2" colspan="4"><%# Eval("stockpile")%></td>
                                <td height="30"  align="left" class="left_txt2" colspan="4"><%# Eval("etTime","{0:yyyy-MM-dd}")%></td>
                                <td height="30"  align="left" class="left_txt2" colspan="4">
                                    <asp:Label ID="lbTuiJian" runat="server" Text='<%# Eval("tuijian") %>'></asp:Label>
                                    <asp:Button ID="lbtnTuiJian" runat="server" Text="更改" CommandName="tuijian" CommandArgument='<%# Eval("id") %>' OnClientClick="return confirm('您真的要更改此商品推荐状态吗?')" />
                                </td>
                                <td height="30"  align="left" class="left_txt2" colspan="4">
                                    <a href='getProductInfo_Admin.aspx?AllId=<%# Eval("id") %>,1,<%=lbNowPage.Text%>' target="main">查看</a>
                                    <a href='getProductInfo_Admin.aspx?AllId=<%# Eval("id") %>,2,<%=lbNowPage.Text%>' target="main">修改</a>
                                    <asp:LinkButton ID="lbtnDelete" runat="server" CommandName="del" CommandArgument='<%# Eval("id") %>' OnClientClick="return confirm('您真的要删除此商品吗? 删除后数据不能恢复!')">删除</asp:LinkButton>
                                    
                                </td>
                          </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </table>
                </td>
              </tr>
              <tr><td>&nbsp;</td></tr>
              <tr>
                <td class="left_txt2" style="text-align:center;">
                          共<asp:Label ID="lbAllPages" runat="server" Text="14" ForeColor="red"></asp:Label>页   
                          当前<asp:Label ID="lbNowPage" runat="server" Text="1" ForeColor="red"></asp:Label>页    
                          <asp:LinkButton ID="lbtnStartPage" runat="server" ForeColor="black" OnClick="lbtnStartPage_Click">首页</asp:LinkButton>  
                          <asp:LinkButton ID="lbtnBeforePage" runat="server"  ForeColor="black" OnClick="lbtnBeforePage_Click">上一页</asp:LinkButton>  
                          <asp:LinkButton ID="lbtnAfterPage" runat="server"  ForeColor="black" OnClick="lbtnAfterPage_Click">下一页</asp:LinkButton>   
                          <asp:LinkButton ID="lbtnLastPage" runat="server"  ForeColor="black" OnClick="lbtnLastPage_Click">尾页</asp:LinkButton>  
                          转到<asp:DropDownList ID="dplJumpPage" runat="server">
                              </asp:DropDownList>    
                          <asp:Button ID="btnGoPage" runat="server" Text="GO" OnClick="btnGoPage_Click"  />
                </td>
              </tr>
            </table>
        </td>
        <td background="images/mail_rightbg.gif">&nbsp;</td>
      </tr>
      <tr>
        <td valign="bottom" background="images/mail_leftbg.gif" style="height: 17px"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
        <td background="images/buttom_bgs.gif" style="height: 17px"><img src="images/buttom_bgs.gif" width="17" height="17"></td>
        <td valign="bottom" background="images/mail_rightbg.gif" style="height: 17px"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
      </tr>
    </table>
    </form>
    </body>
      

  2.   

    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"删除成功!\")</script>");
    运行后..这条语句就被执行后,就没有跳出提示框,所有的都是这类情况
      

  3.   


    if (e.CommandName == "del")
      {
    string message="";
      if (dPoduct.DeleteProductForId(DeleteProductId))
      {
     
       // Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"删除成功!\")</script>");
           message="删除成功!";
      }
      else
      {
         //Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"删除失败! 请重新操作\")</script>");
            message="删除失败! 请重新操作!";
      }
      }
      else if (e.CommandName == "tuijian")
      {
         //Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + (e.Item.FindControl("lbTuiJian") as Label).Text + "')</script>");
        message=(e.Item.FindControl("lbTuiJian") as Label).Text;
      }
     rptGetInfo_Bind(int.Parse(lbNowPage.Text));
       //因为这句Response.Redirect 所以不会弹框
       //Response.Redirect(Request.RawUrl);  
    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('"+message+"');window.open('"+Request.RawUrl+"');</script>");
     
      

  4.   

    Response.Redirect(Request.RawUrl);
    这句 重定向了