Hello,
Please have a look at my VB/ASP code and tell me if you can see what's wrong (I have bolded the important segments):
Basically, I'm trying to get the Page_Load subroutine to execute on the page load, but it doesn't seem to be called. I'm assuming that because I set my feedback label to "feedback" in the Page_Load subroutine, I should see it displayed on the page saying "feedback" on first loading the page and every time I refresh. But this doesn't happen. I'm lead to conclude that the Page_Load subroutine is not being called on the page load.Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <%@Page Explicit="true" Language="VB" Debug="true" Autoeventwireup="false" EnableSessionState="False" EnableViewState="False" %> <%@ Import Namespace="System.Web.Mail" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="MySql.Data.MySqlClient" %> <html> <head> <title>Autobody</title> </head> <script runat="server"> Dim Connection As MySqlConnection Dim MDA As MySqlDataAdapter Dim DS As DataSet Sub Page_Load(sender As Object, e As EventArgs) username_textbox.Text = String.Empty password_textbox.Text = String.Empty feedback_label.Text = "feedback" End Sub Function Connect() As String Dim ConStr As String = "server=localhost; user id=gib; password=gibpw; database=autobody;" Connection = New MySqlConnection(ConStr) MDA = new MySqlDataAdapter() DS = new DataSet() Connection.open() Return "OK" End Function Function Disconnect() As String Connection.close() Return "OK" End Function Sub SubmitButton_Clicked(Sender As Object, E As EventArgs) If Not (Connect() = "OK") Then feedback_label.Text = "Error connecting" Return End If FillDataSet() If Not (Disconnect() = "OK") Then feedback_label.Text = "Error disconnecting" Return End If Authenticate() End Sub Sub FillDataSet() Dim Command As New MySqlCommand Dim Query As String Query = "SELECT * FROM CLIENTS;" Command.Connection = Connection Command.CommandText = Query MDA.SelectCommand = Command MDA.Fill(DS) MDA.dispose() Command.dispose() End Sub Sub Authenticate() Dim username As String Dim password As String Dim i As Integer For i = DS.Tables(0).Rows.Count-1 to 0 Step -1 username = DS.Tables(0).Rows(i).Item("username") If username = username_textbox.Text.Trim() Then password = DS.Tables(0).Rows(i).Item("password") If password = password_textbox.Text Then Response.Redirect("access_granted.html") Else Exit For End If End If Next feedback_label.Text = "Access denied" End Sub </script> <body> <form runat="server"> <table cellpadding=0 cellspacing=0 border=1> <tr><td colspan=2>Please log in:</td></tr> <tr> <td>Username:</td> <td style="width: 200px;"><asp:textbox style="width: 200px;" id="username_textbox" text="" runat="server"/></td> </tr> <tr> <td>Password:</td> <td style="width: 200px;"><asp:textbox style="width: 200px;" id="password_textbox" text="" textmode="password" runat="server"/></td> </tr> <tr><td colspan=2><asp:button id="login_button" text="login" onclick="SubmitButton_Clicked" runat="server" /></td></tr> <tr><td colspan=2><asp:label id="feedback_label" ForeColor="red" runat="server" /></td></tr> </table> <!-- AutoPostBack=true --> </form> </body> </html>
Can anyone tell why?
You can view the site at: http://www.shahspace.com/autobody/index.aspx
Thanks for your help.



Reply With Quote

Bookmarks