ASP.net pass onclick values to another page

2

On the first aspx page I have 2 buttons with difficulty for my game (normal and difficult)

<div class="modal-body">
          <asp:ImageButton id="normal" ImageUrl="~/images/flecha_atras.png" class="flechaAtras" onclick="normal_Click" runat="server"/>
            <asp:ImageButton id="dificil" ImageUrl="~/images/flecha_atras.png" class="flechaAtras" onclick="dificil_Click" runat="server"/>
</div>

The 2 buttons redirect me to another aspx page

public void normal_Click(object sender, EventArgs e)
    {
        Response.Redirect("Puzzle5.aspx");
    }

public void dificil_Click(object sender, EventArgs e)
    {
        Response.Redirect("Puzzle5.aspx");
    }

On that 2nd page aspx I have the following script

$(function() {
    setTimeout(
        game.load(
            'procrastination_color2', 
            2, 
            3,
            'mandala'
        ), 333);
});

Based on the values 2 and 3, I put together a page with lots of puzzle pieces.

What I want to do is send from the first page, according to which button to press, different values.

For example if the first page is clicked NORMAL button, command (2,3) If you click hard button, to the other aspx page, inside the script, I want to send values (8,5)

I do not know how I can do that. Any idea people?

    
asked by Oren Diaz 05.04.2018 в 19:04
source

1 answer

2

If I understood well what you want to do, you can do it in two ways. According to the button that you click, send concatenated to the URL the value you want.

public void normal_Click(object sender, EventArgs e)
    {
        string valor;

        Response.Redirect("Puzzle5.aspx?valor=" + valor);
    }

public void dificil_Click(object sender, EventArgs e)
    {
        string valor;
        Response.Redirect("Puzzle5.aspx?valor=" + valor);
    }

And in the load, of the screen that you open, you receive the value by means of a request Page.Request ();

If you wish to do with JavaScript, the request is maintained in the same way, and it only changes how you open the page you want.

var ruta = "URL.aspx?valor=123434";
window.open(ruta, ruta, "status=yes,toolbar=no,menubar=no,location=no, fullscreen=no, scrollbars=yes, resizable=yes")

I do not use much C # so that code is very improvable, I hope it serves you. Greetings.

    
answered by 05.04.2018 / 19:35
source