Hi all I am relatively new to ASP.NET and would appreciate a little help with a problem I am having. I have a "login" page that (upon validation of username/password) loads up another page. Now I have both these pages (I am using c# btw) written, however I cannot find the (probably one line of) code that I need to get the login screen to launch the second screen. Thanks for your time.

10 Years
Discussion Span
Last Post by majestic0110

Sorry forgot to add code for login form

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    void Button1_Click(Object Source, EventArgs E)
        if(TextBox1.Text=="" && TextBox2.Text=="")
            Label1.Text = "OK";
            Label1.Text = "Invalid input";

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Login Page</title>
    <form id="form1" runat="server">
        Please enter your credentials:<br />
        <br />
        Username:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
        <br />
        Password:<asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox><br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Login" OnClick="Button1_Click" />
        <asp:Label ID="Label1" runat="server"></asp:Label><br />
        <br />

you need a response.redirect to the correct page, or server.transfer. However, you should set a unique id in a session variable for the user. Then have a protection script to run on every page much like:

if (session["userid"] == "") { response.redirect("login.aspx") }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.