Home > Blockchain >  How to change view in asp.net?
How to change view in asp.net?

Time:05-14

Im wondering how i can change "views" with a button click in Visual Studio (asp.net)?

I have 2 .aspx files, one called Default.aspx and another one called Library.aspx. How can i make a button change the views to display the other aspx file?

I tried googling but didnt find anything useful. Any help here is appreciated. Thanks

CodePudding user response:

Ok, assuming default.aspx is in desing mode, then just drop a button from the toolbox onto the web page.

Say, like this:

enter image description here

Now, double click on the button, and we are jumped to code behind.

    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("Library.aspx");
    }

So, we put for the code to jump to the web page Library.aspx

We get this then:

enter image description here

And now, when I click on that button, I am jumped to the web page called Library.aspx - we should see this (assuming the web page Library.aspx exists).

enter image description here

  • Related