Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

I am trying to make if statement in the master page so that it can open a page.

HTML
protected void Button1_Click(object sender, EventArgs e)
    {

        if 
        {

            Response.Redirect("login.aspx");

        }
        
        else
            {
             
                Response.Redirect("Default.aspx");
                   
            }
    }


if the button text reads login i need to go to default.aspx and if it reads logout then i need to go to login.aspx

thanks,
Posted

1 solution

Try
Button b = (Button) sender;

if (b.Text == "login")
{
    Response.Redirect("login.aspx");
}       
else
{
    Response.Redirect("Default.aspx");    
}
 
Share this answer
 
v3
Comments
Small mistake... It should be...

if (b.Text == "login")
CHill60 15-Dec-15 4:41am    
Oops! I've been over to the dark side - VB! But I think I'm back safely.
Thank you, I'll update the solution
Haha. You updated the wrong line. Are you still inside blankets? ;) :P

Updating for you. :)
CHill60 15-Dec-15 9:25am    
Thanks again ... brain definitely not in the right gear today! :facepalm:
No problem buddy. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900