Open asp: visible panel = true from a link in a different file

1

Greetings. I have 3 panels with visible=false and in .cs the method that shows one or the other according to the button that is pressed, but all this is within the same file products.aspx/.cs . What happens if I want to execute the panel.visible = true but from an external link another different file, for example from index.aspx .

I enclose drawing if I make myself understand better.

protected void Button_ProductosClick_1(object sender, EventArgs e)
{
    this.PanProductsOne.Visible = true;
    this.PanProductsTwo.Visible = false;
    this.PanProductsThree.Visible = false;

}
protected void Button_ProductosClick_2(object sender, EventArgs e)
    {
        this.PanProductsOne.Visible = false;
        this.PanProductsTwo.Visible = true;
        this.PanProductsThree.Visible = false;

    }
protected void Button_ProductosClick_3(object sender, EventArgs e)
    {
        this.PanProductsOne.Visible = false;
        this.PanProductsTwo.Visible = false;
        this.PanProductsThree.Visible = true;

}
    
asked by Vulpex 06.07.2017 в 19:30
source

2 answers

1

You can pass values between pages by means of a querystring:

On your buttons the redirect would do so (depending on the button is the value of var):

Response.Redirect("products.apsx?var=1");

And on your page products.aspx, in the page_load event, you retrieve the value like this:

string strVar = request.querystring["var"];

Already with the value of the query string, you can use an if or a switch to show the corresponding panel.

    
answered by 06.07.2017 / 20:00
source
0

Solved as follows:

[default.cs]

protected void Button_ProductosClick_1(object sender, EventArgs e)
    {

        Response.Redirect("http://192.168.48.26/contenido/productos.aspx?showview=tff");
    }
    protected void Button_ProductosClick_2(object sender, EventArgs e)
    {

        Response.Redirect("http://192.168.48.26/contenido/productos.aspx?showview=ftf");
    }
    protected void Button_ProductosClick_3(object sender, EventArgs e)
    {

        Response.Redirect("http://192.168.48.26/contenido/productos.aspx?showview=fft");
    }

products.cs

protected void Page_Load(object sender, EventArgs e)
    {
        string strVar = Request.QueryString["showview"];
        if (strVar == "tff") 
        {
            this.PanProductsOne.Visible     = true;
            this.PanProductsTwo.Visible     = false;
            this.PanProductsThree.Visible   = false;
            Page.ClientScript.RegisterStartupScript(GetType(), "Getposition", "<script>window.location='#PosA';</script>");
        }
        if (strVar == "ftf" ) {
            this.PanProductsOne.Visible     = false;
            this.PanProductsTwo.Visible     = true;
            this.PanProductsThree.Visible   = false;
            Page.ClientScript.RegisterStartupScript(GetType(), "Getposition", "<script>window.location='#PosA';</script>");
        }
        if (strVar == "fft")
        {
            this.PanProductsOne.Visible     = false;
            this.PanProductsTwo.Visible     = false;
            this.PanProductsThree.Visible   = true;
            Page.ClientScript.RegisterStartupScript(GetType(), "Getposition", "<script>window.location='#PosA';</script>");
        }


    }

Encode in "tff" the variable that is (true false false) abbreviated, and then I picked up the value in the products.cs that if it is == a "tff" then show and hide the necessary panels according to if(){} . Thanks to @Victor Aparicio for the track of where the thing was.

    
answered by 06.07.2017 в 21:17