Solved

Login trouble

Posted on 2003-11-08
6
219 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Date Picker 64 bit 32 bit issue 12 53
VBA Shell can't Find Word document 11 92
How to make an ADE file by code? 11 83
Protecting vb6 & .Net code Obfuscation 18 121
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

786 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