1

我想根据 ddlCat 和 ddlSubCat(Dropdownlist) 的选择将“Manage-Cat-Subcat.aspx”从“Mainpage.aspx”重定向到显示 panel1 和 panel2...

重定向到“Manage-Cat-Subcat.aspx”页面以显示Panel1:

protected void ddlcat_SelectedIndexChanged(object sender, EventArgs e)
{
    if (ddlcat.SelectedItem.Text == "Other...")
    {
        Response.Redirect("ManageCat-SubCat.aspx?Register=pnlCat");
    }
}

重定向到“Manage-Cat-Subcat.aspx”页面以显示Panel2:

protected void ddlsubcat_SelectedIndexChanged(object sender, EventArgs e)

{
    if (ddlsubcat.SelectedItem.Text == "Other...")
    {
        Response.Redirect("ManageCat-SubCat.aspx?Register=pnlSubCat");

    }

}

这就是我在 Manage-Cat_Subcat.aspx 中尝试根据“注册”中的值显示的内容

protected void Page_Load(object sender, EventArgs e)
{
    if (Request.QueryString["Register"] = pnlCat)
    {
        Panel1.Visible = true;
    }
    else if (Request.QueryString["Register"] = pnlSubCat)
    {
        Panel2.Visible = true;
    }

谢谢!!

4

2 回答 2

0

在您的ManageCat-SubCat.aspx您可以检查值Request.QueryString["Register"]并根据该值设置 Panel2 和 Panel1 的可见性

protected void Page_Load(object sender, EventArgs e)
{
    bool visible = Request.QueryString["Register"] == "pnlCat";

    Panel1.Visible = visible;
    Panel2.Visible = !visible;
 }
于 2013-08-14T05:16:45.603 回答
0

主页

protected void ddlcat_SelectedIndexChanged(object sender, EventArgs e)
{
    if (ddlcat.SelectedItem.Text == "Other...")
    {
        Response.Redirect("ManageCat-SubCat.aspx?Register=pnlCat");
    }
}

protected void ddlsubcat_SelectedIndexChanged(object sender, EventArgs e)

{
    if (ddlsubcat.SelectedItem.Text == "Other...")
    {
        Response.Redirect("ManageCat-SubCat.aspx?Register=pnlSubCat");

    }

}

Manage-Cat-Subcat.aspx

protected void Page_Load(object sender, EventArgs e)
{
panel1.visible=false;
panel2.visible=false;
if(Request.QueryString["Register"]=="pnlCat")
{
panel1.visible=true;
}
if(Request.QueryString["Register"]=="pnlSubCat")
{
panel2.visible=true;
}
}
于 2013-08-14T05:18:16.437 回答