Nigel Whitworth's Development Site

You are currently not logged in.

ASP.NET Interacting

In the old style ASP, to validate the information that the user has entered required the code to be on another page to the page that had designed the page. In ASP.NET, it now works along the lines of a VB form. Code that deals with what the user has entered is on the same page as the HTML. Consider a page that has a simple log on script, one that validates the user has entered GREEN1 as the user name and GREEN2 as the password. Only when the condition has been met does the user access the next page PAGE2.aspx Below is how it could be done. ASP.NET does have advanced authentication routines but that is beyond this page.

<HTML>
    <script language=VB runat=server>
        
        sub ValidateBtn_Click(sender as object, e as EventArgs)
            if txtUser.text="GREEN1" and txtPass.text="GREEN2" then
                Response.Redirect("PAGE2.aspx")
            else
                lblMessage.text = "Incorrect Username and password."
            end if
        end sub

    </script>

    <Body>
    
        <ASP:Label id=lblMessage runat=server />
    
        <Form runat="server">
        <Table width=100%>
        <TR><TD>User name</TD><TD><ASP:TextBox id=txtUser runat=server /></TD></TR>
        <TR><TD>Password</TD><TD><ASP:TextBox id=txtPass runat=server /></TD></TR>
        <TR><TD><ASP:Button text="Validate" OnClick="ValidateBtn_Click" runat=server /></TD><TD>< ></TD></TR>
        </Table>
        </Form>
    </Body>
</HTML>




If you intend to vote or make a comment, please enter the security code.

Make a comment

*Comments are the views of individuals, they may or may not be correct.
All comments are reviewed and accepted or rejected.
If you give an email address, you will be sent an email when someone makes a comment on this page.*

Name :
Email :
Comments :


Only name and Code is compulsory.
 
 
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)