Solved

Login trouble

Posted on 2003-11-08
6
218 Views
Last Modified: 2010-05-03
I created a Web Application Project using VB.NET, I have a login form for users to login to the account, Now I have a username and password field for the user to fill in to enter their account, So after the user fills up the username and fills up the password field and hits enter, instead of entering the user account the page is reloaded, as in user accounts usually after filling up the password the user hits enter instead of clicking on the login button with the mouse.....so why does my application not work the way it usually does, like after filling the password field the user clicks enter and then enters his account....



Please ask if someone did not understand my question or needs more information....


0
Comment
Question by:Moizsaif123
  • 2
  • 2
6 Comments
 
LVL 2

Assisted Solution

by:gimmeadrink
gimmeadrink earned 45 total points
ID: 9708914
Can you post the code for the form. Its hard to work out what is wrong without it.

ta
0
 
LVL 4

Author Comment

by:Moizsaif123
ID: 9709750
My problem has the same concept as in the Login page in this website,
http://www.experts-exchange.com, when I fill in my user name and password ,I do not have to manually use the mouse to click Login, I can hit enter and the user logins the page.....In .NET on the other hand if I hit enter instead of using the mouse to click the Login button the page reloads......I will post my code .....
0
 
LVL 5

Accepted Solution

by:
fantasy1001 earned 100 total points
ID: 9712527
You have to set the default to your submit button. The Login button should set to the submit type.

~ fantasy ~
0
 
LVL 4

Author Comment

by:Moizsaif123
ID: 9715145
fantasy1001,

My Html code is,and the Id of my Login button is ,'Submit1'....



<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Login.aspx.vb" Inherits="Patients_Web_Proj.Login"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <title>WebForm2</title>
            <meta content="True" name="vs_showGrid">
            <meta content="False" name="vs_snapToGrid">
            <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
            <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
            <meta content="JavaScript" name="vs_defaultClientScript">
            <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
            <SCRIPT language="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- John Munn  (jrmunn@home.com) -->

<!-- Begin
 function putFocus(formInst, elementInst) {
  if (document.forms.length > 0) {
   document.forms[formInst].elements[elementInst].focus();
  }
 }
// The second number in the "onLoad" command in the body
// tag determines the form's focus. Counting starts with '0'
//  End -->
            </SCRIPT>
      </HEAD>
      <body bgColor="#d9e5ff" topMargin="50" onload="putFocus(0,1);" MS_POSITIONING="GridLayout">
            <form id="Form1" name="testForm" runat="server">
                  &nbsp;
                  <asp:panel id="Panel2" style="Z-INDEX: 101; LEFT: 0px; POSITION: absolute; TOP: 0px" runat="server" BorderWidth="8px" BackColor="LightSteelBlue" BorderColor="CornflowerBlue" BorderStyle="Outset" Height="46px" Width="992px">
                        <FONT style="BACKGROUND-COLOR: #c0ffff"></FONT>
                  </asp:panel><asp:label id="Lbl_PtnDemo" style="Z-INDEX: 102; LEFT: 438px; POSITION: absolute; TOP: 12px" runat="server" BackColor="LightSteelBlue" Height="21px" Width="51px" Font-Italic="True" Font-Size="Medium" Font-Bold="True">Login </asp:label>&nbsp;
                  <asp:panel id="Panel1" style="Z-INDEX: 103; LEFT: 286px; POSITION: absolute; TOP: 132px" runat="server" BackColor="ActiveBorder" BorderColor="ActiveCaption" BorderStyle="Groove" Height="205px" Width="368px">
                        <P>&nbsp;</P>
                        <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
                        <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
                  </asp:panel><asp:textbox id="TBUsrName0" style="Z-INDEX: 104; LEFT: 404px; POSITION: absolute; TOP: 168px" tabIndex="1" runat="server" Height="24px" Width="178px"></asp:textbox><asp:textbox id="TB_Password" style="Z-INDEX: 105; LEFT: 405px; POSITION: absolute; TOP: 217px" tabIndex="2" runat="server" Height="24px" Width="178px" TextMode="Password"></asp:textbox><asp:button id="Button2" style="Z-INDEX: 106; LEFT: 495px; POSITION: absolute; TOP: 260px" runat="server" Height="23px" Width="104px" Text="Cancel"></asp:button><INPUT id="Submit1" style="Z-INDEX: 107; LEFT: 354px; WIDTH: 112px; POSITION: absolute; TOP: 260px; HEIGHT: 23px" onclick="document_onclick()" tabIndex="2" type="submit" value="Submit" name="Submit1" runat="server">
                  <a href="http://10.32.0.76/Patients-Web-Proj/Demo_Ptn.aspx">
                        <asp:linkbutton id="LinkButton1" style="Z-INDEX: 108; LEFT: 540px; POSITION: absolute; TOP: 305px" runat="server" BackColor="ActiveBorder" Height="18px" Width="102px" Font-Italic="True" Font-Names="Estrangelo Edessa">New Patient</asp:linkbutton></a><asp:label id="Label1" style="Z-INDEX: 109; LEFT: 318px; POSITION: absolute; TOP: 170px" runat="server" BackColor="ActiveBorder" Height="20px" Width="72px" Font-Names="Arial Narrow">UserName</asp:label><asp:label id="Label2" style="Z-INDEX: 110; LEFT: 326px; POSITION: absolute; TOP: 220px" runat="server" BackColor="ActiveBorder" Height="20px" Width="72px" Font-Names="Arial Narrow">Password</asp:label></form>
      </body>
</HTML>
0
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9718896
Simply add the following line to your page's Load event, replacing "btnSearch" with the name of your button. It uses a hidden Page method called RegisterHiddenField and works splendidly:

Page.RegisterHiddenField("__EVENTTARGET", "Submit1")

~ fantasy ~
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now