Dear Colleagues:

I want to separate interface design from its code (in my asp.net school project). So that , I'm trying to use a code-behind using vb.net. For example in my login page I provide the user with username and password input, then handle the user input from lgoin.vb file. But I don't know how to get the values of textbox that are placed in login.aspx file.

How Can access these username and password textbox values in the login.vb code to check the user input. To give u some idea about my code, just see the following simple code:

************************
login.aspx
************************

<%@ page Inherits ="class1" scf="lgoin.vb"%>

<html>
<head></head>
<body>
<form id="form1" runat="server">

<asp:TextBox ID="txtuname" runat="server"/>
<asp:TextBox ID="txtpass" runat="server"/>
<asp:Button ID="btnlog" runat="server" Text="Button" OnClick ="button_click" />
</form>
</body>
</html>
************************
login.vb
************************
Imports Microsoft.VisualBasic
Imports system.Web
Imports system.Web.UI
Imports system.Web.UI.Control
Imports system.Web.UI.HtmlControls

Public Class Class1
Inherits Page

Sub button_click(ByVal s As Object, ByVal e As EventArgs)
'based on the the user input(username and passward)
' I want to redirect the users to different pages
' if txtpass.text= "x" and txtuname="something" then

'Response.Redirect("x.aspx")
'else
'Response.Redirect("y.aspx")
End Sub
End Class
************************
As u have seen from the code I commented some lines on login.vb file. This is because I can't access the txtuname and txtpass textboxes from lgoin.vb.


Please help me how can I do that


Regards,

Ben

So for starters, make sure the spelling of your filenames are all correct. I mean, you're going back and forth between "lgoin" and "login". That's bound to lead to confusion.

I just made a brand new ASPX page and the first line looked like this:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

so from that standpoint, I would imagine you would be looking at this:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Login.vb" Inherits="Class1" %>

I'd make sure that all the capitalization is as it should be-- that makes a difference with C#, but I'm not sure with VB.NET.

This article has been dead for over six months. Start a new discussion instead.