Hi,

Stone me now. I am not a programmer or even a web developer. I am however falling victim to a strong learning curve - I have been asked to look at a site that is having a problem and fix it, and its imperative that I do so :)

The problem that I am having is with a page called login.aspx - this is obviously a login page. Everything works great in mozilla. When I call the page up in IE the page loads fine, but nothing happens when I enter a used id and submit.

The code, from what I can tell, on the formside looks very standard, almost as if it was cut and pasted from a tutorial.

<form id="Form1" method="post" runat="server">
                <h3><font face="Verdana">Login Page</font></h3>
                <span class="Normal">Company ID:</span> <br>
                <input class="NormalTextBox" id="CustomerCode" type="text" name="UserEmail" runat="server">
                <ASP:REQUIREDFIELDVALIDATOR id="Requiredfieldvalidator1" runat="server" ErrorMessage="You Must Enter a Valid Company ID." Display="Static" ControlToValidate="CustomerCode" Width="276px" cssclass="NormalRed"></ASP:REQUIREDFIELDVALIDATOR>
                <br>
                <br>
                <ASP:CHECKBOX id="PersistForms" runat="server" autopostback="true" text="Remember me" cssclass="Normal"></ASP:CHECKBOX>
                <br>
                <br>
                <asp:imagebutton id="SigninBtn" runat="server" ImageUrl="~/images/signin.gif"></asp:imagebutton><br>
                <asp:label id="Msg" runat="server" cssclass="NormalRed"></asp:label>
              </form>

The authentification portion of the web.config reads like this :

<authentication mode="Forms">
	        <forms loginUrl="login.aspx" name=".ASPXAUTHSC" protection="All" timeout="60"/>
		</authentication>

Finally, the login.aspx.vb is apparently some stock code generated from some code generator...

Imports System.Security
Imports System.Web.Security

Public Class Login
    Inherits System.Web.UI.Page
    Protected WithEvents Requiredfieldvalidator1 As System.Web.UI.WebControls.RequiredFieldValidator
    Protected WithEvents PersistForms As System.Web.UI.WebControls.CheckBox
    Protected WithEvents Msg As System.Web.UI.WebControls.Label
    Protected WithEvents SigninBtn As System.Web.UI.WebControls.ImageButton
    Protected WithEvents CustomerCode As System.Web.UI.HtmlControls.HtmlInputText

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub

    Public Sub Login_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles SigninBtn.Click
        Dim security As New ASPNetPortal.UsersDB()

        Dim userId As String = security.Login(CustomerCode.Value.ToString())

        If Not (userId Is Nothing) And userId <> "" Then
            FormsAuthentication.RedirectFromLoginPage _
                               (userId, PersistForms.Checked)
        Else

            Msg.Text = "<" & "br" & ">Login Failed!" & "<" & "br" & ">"

        End If



    End Sub

    
    
End Class

I know enough about this to get myself into a heap of trouble, and im probably looking in the wrong place. For all I know it could be a browser issue for end users who dont have the right browser version or .net version running. I dont know.

Any help would be appreciated, if you need more info feel free to let me know!


Mike E

Ok, I am tired so bare that in mind.

But where is the event tied to the SignIn ImageButton? That is the submit button correct?

Is the code for this Login_Click is not tied to any object in the HTML side of the ASP.Net page?

Saying that, I am surprised it worked in Mozzilla. But from the code you have provided, the only reason it would not work is for the simple fact that there is not event coded for the On_Click of the ImageButton (your signIn Button).


Hope this helps
:cool:

Hi,

Stone me now. I am not a programmer or even a web developer. I am however falling victim to a strong learning curve - I have been asked to look at a site that is having a problem and fix it, and its imperative that I do so :)

The problem that I am having is with a page called login.aspx - this is obviously a login page. Everything works great in mozilla. When I call the page up in IE the page loads fine, but nothing happens when I enter a used id and submit.

The code, from what I can tell, on the formside looks very standard, almost as if it was cut and pasted from a tutorial.

<form id="Form1" method="post" runat="server">
                <h3><font face="Verdana">Login Page</font></h3>
                <span class="Normal">Company ID:</span> <br>
                <input class="NormalTextBox" id="CustomerCode" type="text" name="UserEmail" runat="server">
<ASP:REQUIREDFIELDVALIDATOR id="Requiredfieldvalidator1" runat="server" ErrorMessage="You Must Enter a Valid Company ID." Display="Static" ControlToValidate="CustomerCode" Width="276px" cssclass="NormalRed"></ASP:REQUIREDFIELDVALIDATOR>
                <br>
                <br>
<ASP:CHECKBOX id="PersistForms" runat="server" autopostback="true" text="Remember me" cssclass="Normal"></ASP:CHECKBOX>
                <br>
                <br>
<asp:imagebutton id="SigninBtn" runat="server" ImageUrl="~/images/signin.gif"></asp:imagebutton><br>
                <asp:label id="Msg" runat="server" cssclass="NormalRed"></asp:label>
              </form>

The authentification portion of the web.config reads like this :

<authentication mode="Forms">
	        <forms loginUrl="login.aspx" name=".ASPXAUTHSC" protection="All" timeout="60"/>
		</authentication>

Finally, the login.aspx.vb is apparently some stock code generated from some code generator...

Imports System.Security
Imports System.Web.Security

Public Class Login
    Inherits System.Web.UI.Page
    Protected WithEvents Requiredfieldvalidator1 As System.Web.UI.WebControls.RequiredFieldValidator
    Protected WithEvents PersistForms As System.Web.UI.WebControls.CheckBox
    Protected WithEvents Msg As System.Web.UI.WebControls.Label
    Protected WithEvents SigninBtn As System.Web.UI.WebControls.ImageButton
    Protected WithEvents CustomerCode As System.Web.UI.HtmlControls.HtmlInputText

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub

    Public Sub Login_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles SigninBtn.Click
        Dim security As New ASPNetPortal.UsersDB()

        Dim userId As String = security.Login(CustomerCode.Value.ToString())

        If Not (userId Is Nothing) And userId <> "" Then
            FormsAuthentication.RedirectFromLoginPage _
                               (userId, PersistForms.Checked)
        Else

            Msg.Text = "<" & "br" & ">Login Failed!" & "<" & "br" & ">"

        End If



    End Sub

    
    
End Class

I know enough about this to get myself into a heap of trouble, and im probably looking in the wrong place. For all I know it could be a browser issue for end users who dont have the right browser version or .net version running. I dont know.

Any help would be appreciated, if you need more info feel free to let me know!


Mike E

Hoowah, now I just have to figure out what its supposed to do OnClick and put all that goodness in there! :)

me™

So this code doesn't handle the process? I'm so lost :)

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub

    Public Sub Login_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles SigninBtn.Click
        Dim security As New ASPNetPortal.UsersDB()

        Dim userId As String = security.Login(CustomerCode.Value.ToString())

        If Not (userId Is Nothing) And userId <> "" Then
            FormsAuthentication.RedirectFromLoginPage _
                               (userId, PersistForms.Checked)
        Else

            Msg.Text = "<" & "br" & ">Login Failed!" & "<" & "br" & ">"

        End If



    End Sub

    
    
End Class

If I am reading you correctly, I need an HTML side On_Click function assigned to that particular line of code....

I should stick to static web pages :)

Mike E

Mike,
What Paladine is saying is ..there is no connection between your VB code and your HTML designer code..(meaning there is no way of event to be tiggered when you click the image button)

To solve:
1.Double click the SigninBtn(image) button and place this code

Dim security As New ASPNetPortal.UsersDB()

        Dim userId As String = security.Login(CustomerCode.Value.ToString())

        If Not (userId Is Nothing) And userId <> "" Then
            FormsAuthentication.RedirectFromLoginPage _
                               (userId, PersistForms.Checked)
        Else

            Msg.Text = "<" & "br" & ">Login Failed!" & "<" & "br" & ">"

        End If

here is where I am confused...

At the top of my login.aspx page (the html page) this code appears

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="login.aspx.vb" Inherits="databasename.Login"%>

In the login.aspx.vb

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub

    Public Sub Login_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles SigninBtn.Click
        Dim security As New ASPNetPortal.UsersDB()

        Dim userId As String = security.Login(CustomerCode.Value.ToString())

        If Not (userId Is Nothing) And userId <> "" Then
            FormsAuthentication.RedirectFromLoginPage _
                               (userId, PersistForms.Checked)
        Else

            Msg.Text = "<" & "br" & ">Login Failed!" & "<" & "br" & ">"

        End If

This is what is there. Im drawing the conclusion that the

Public Sub Login_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles SigninBtn.Click
        Dim security As New ASPNetPortal.UsersDB()

        Dim userId As String = security.Login(CustomerCode.Value.ToString())

        If Not (userId Is Nothing) And userId <> "" Then
            FormsAuthentication.RedirectFromLoginPage _
                               (userId, PersistForms.Checked)
        Else

            Msg.Text = "<" & "br" & ">Login Failed!" & "<" & "br" & ">"

        End If

should handle the actual On_Click...


Im getting and parsing all of this in dreamweaver so i'm not really sure how double clicking an image will let me fill in the code that operates the image.

Like I said, this is a mess I am in and I appreciate the feedback, eventually I will get this figured out and hopefully be able to learn this :)

Mike

NEW INFO - client is telling me that this worked until recently - in IE and mozilla, which leads me to wonder if an update to IE has changed something..

Any ideas?

Me™

Ok, no update would change this. The code got changed. Period!

The VB Code for Login_Click event (see your code below) is not tied to anything on the HTML side that would activate it. (Make sense?)

So you have to associate that code to a control (from the HTML) side inorder for the event to fire. So do this:

As LetsCode stated:

1. Double Click on the SignIn Image Button (in Design view of the HTML code) to create the event SignIn_Click on the VB Code side.
2. Then copy and paste the code from Login_Click event into the newly created SignIn_Click event. **NOTE** DO NOT Copy and paste the code I am giving you to show you the result, actually do the process I have described

Result would be:

Public Sub SigninBtn_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles SigninBtn.Click
 Dim security As New ASPNetPortal.UsersDB()

        Dim userId As String = security.Login(CustomerCode.Value.ToString())

        If Not (userId Is Nothing) And userId <> "" Then
            FormsAuthentication.RedirectFromLoginPage _
                               (userId, PersistForms.Checked)
        Else

            Msg.Text = "<" & "br" & ">Login Failed!" & "<" & "br" & ">"

        End If
End Sub

make sense I hope?

:cool:

Your POST:

here is where I am confused...

At the top of my login.aspx page (the html page) this code appears

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="login.aspx.vb" Inherits="databasename.Login"%>

In the login.aspx.vb

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub

    Public Sub Login_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles SigninBtn.Click
        Dim security As New ASPNetPortal.UsersDB()

        Dim userId As String = security.Login(CustomerCode.Value.ToString())

        If Not (userId Is Nothing) And userId <> "" Then
            FormsAuthentication.RedirectFromLoginPage _
                               (userId, PersistForms.Checked)
        Else

            Msg.Text = "<" & "br" & ">Login Failed!" & "<" & "br" & ">"

        End If

This is what is there. Im drawing the conclusion that the

Public Sub Login_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles SigninBtn.Click
        Dim security As New ASPNetPortal.UsersDB()

        Dim userId As String = security.Login(CustomerCode.Value.ToString())

        If Not (userId Is Nothing) And userId <> "" Then
            FormsAuthentication.RedirectFromLoginPage _
                               (userId, PersistForms.Checked)
        Else

            Msg.Text = "<" & "br" & ">Login Failed!" & "<" & "br" & ">"

        End If

should handle the actual On_Click...


Im getting and parsing all of this in dreamweaver so i'm not really sure how double clicking an image will let me fill in the code that operates the image.

Like I said, this is a mess I am in and I appreciate the feedback, eventually I will get this figured out and hopefully be able to learn this :)

Mike

Try what Paladine said...

May be it should work...

Trust me....

try what I suggested first. Then report back if no change.


Oh, be sure to COMMENT out the Login_Click event (DONT DELETE IT).

Try what Paladine said...

May be it should work...

Paladine,
why does sometimes even if you code it correctly in both the designer and code behind (without actually double clicking it) doesnt work.

I had this problem once.I deleted a button and recreated it and assigned the same id as the previous one and when I executed the program,the button click was not recognising its events..
I had to go back and double click the button manually then when I executed it ...It worked fine...

Here Mike used something like

"Public Sub Login_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles SigninBtn.Click"

but he included signinBtn.click in the handler...It has to work..No matter what the name of the function Login_click or signinBtn_click??

I'm just curious...

Yeah I understand exactly what you are saying. But for whatever reason code corruption happens. It all my experience I have find that recreating the event code by the method I describe works / fixes the issue. Hard coding works as well, but with less certainty.... in my experience anyway. Something to do with the windows generated code portion, I am not sure.

I know what you are saying about the Handles, but for sense of certainty, keeping the names of the events to be linked to the object is key not only for ensuring functionality, but also clarity of the code.

IMHO
:cool:

Paladine,
why does sometimes even if you code it correctly in both the designer and code behind (without actually double clicking it) doesnt work.

I had this problem once.I deleted a button and recreated it and assigned the same id as the previous one and when I executed the program,the button click was not recognising its events..
I had to go back and double click the button manually then when I executed it ...It worked fine...

Here Mike used something like

"Public Sub Login_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles SigninBtn.Click"

but he included signinBtn.click in the handler...It has to work..No matter what the name of the function Login_click or signinBtn_click??

I'm just curious...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.