jumpseatnews
asked on
Strange ASP.NET Submit Button Behavior
Hi Experts,
I'm having a lot of trouble with this one.
A simple textbox control and a button control. If a visitor types a number into the textbox, and then clicks the 'submit' button with the mouse, the onclick event runs a subroutine that does a membership check. All is well.
However, if the person simply types their member number into the text box and presses ENTER, the page appears to post back but no data is processed.
Any idea what is going on? This is driving me NUTS!!
Here's the complete code. Any help would be appreciated.
<%@ Page Language="VB" EnableViewState="false" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Sql Client" %>
<%@ Import Namespace="System.Configur ation" %>
<%@ Register Assembly="PeterBlum.VAM" Namespace="PeterBlum.VAM" TagPrefix="VAM" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script runat="server">
Protected Sub btnCheckAccount_Click(ByVa l sender As Object, ByVal e As System.EventArgs)
Dim MyConnection As SqlConnection
Dim MyCommand As SqlCommand
Dim MyReader As SqlDataReader
Dim IDParam As SqlParameter
Dim CheckIfActive As Boolean
Dim CheckEmailAddress As String
MyConnection = New SqlConnection(Configuratio nManager.A ppSettings ("MM_CONNE CTION_STRI NG_APDTMai n"))
MyCommand = New SqlCommand()
MyCommand.CommandText = "SELECT * from vw_MemberStatusCheck WHERE Account = @ID"
MyCommand.CommandType = CommandType.Text
MyCommand.Connection = MyConnection
IDParam = New SqlParameter()
IDParam.ParameterName = "@ID"
IDParam.Value = txtAccount.Text
MyCommand.Parameters.Add(I DParam)
MyCommand.Connection.Open( )
MyReader = MyCommand.ExecuteReader(Co mmandBehav ior.CloseC onnection)
pnlNoRecords.Visible = True
pnlActive.Visible = False
pnlExpired.Visible = False
While MyReader.Read
txtDateExpire.Text = MyReader("DateExpire").ToS tring()
txtFirstName.Text = MyReader("FirstName")
txtFirstNameActive.Text = MyReader("FirstName")
txtMemberType.Text = MyReader("MemberType")
cbxActive.Checked = MyReader("Active")
txtAccount.Text = MyReader("Account")
CheckIfActive = MyReader("InitialSuccessPm t")
CheckEmailAddress = MyReader("Email")
If cbxActive.Checked = True Then
pnlActive.Visible = True
pnlExpired.Visible = False
pnlNoRecords.Visible = False
Else
End If
If cbxActive.Checked = False Then
pnlExpired.Visible = True
pnlActive.Visible = False
pnlNoRecords.Visible = False
Else
End If
If CheckIfActive = True Then
pnlNotYetActive.Visible = True
pnlSendEmail.Visible = True
pnlExpired.Visible = False
pnlActive.Visible = False
pnlNoRecords.Visible = False
End If
End While
MyCommand.Dispose()
MyConnection.Dispose()
End Sub
</script><title>Forgot Your Password?</title>
<!--#include virtual="/assets/inc/cmn/h eadcnt.inc " -->
<style type="text/css" media="all">
table.tablelistnb td.lbl{padding-right:0;}
table.tablelistnb{margin-b ottom:-5px ;margin-to p:7px;marg in-left:3p x;}
#btnLogin{font-size:115%;f ont-weight :bold;}
input.errorbackground{back ground:#FF F9E1;}
#bkground{padding-bottom:7 px;margin- top:10px;m argin-bott om:10px;bo rder:1px solid #ccc;background:#F7F7FA;wi dth:350px; }
</style>
<script type="text/JavaScript" src="/assets/js/popup.js"> </script>
</head>
<body id="twocol">
<h1 Membership Status</h1>
<p>Enter your Member Number in the box below to check your APDT Membership status.</p>
<form id="frmLogin" style="margin-bottom: 0.5em" runat="server">
<table border="0" cellpadding="0" cellspacing="0" class="tablelistnb">
<tr>
<td nowrap="nowrap" class="lbl" style="text-align:right">< label for="txtUsername">APDT Member #</label></td>
<td width="100%"><asp:TextBox ID="txtAccount" runat="server" Size="6" MaxLength="6" TabIndex="1" ToolTip="Type your APDT Membership Number in this box." /> <span class="small"><VAM:DataTyp eCheckVali dator ID="DataTypeCheckValidator 1" runat="server" ControlIDToEvaluate="txtAc count"
DataType="Integer" ErrorFormatter="Text (class: TextErrorFormatter)" ErrorMessage="Numbers only, please.">
<ErrorFormatterContainer>
<VAM:TextErrorFormatter Display="Dynamic" ForeColor="Red" />
</ErrorFormatterContainer>
</VAM:DataTypeCheckValidat or>
<VAM:RequiredTextValidator ID="RequiredTextValidator1 " runat="server" ControlIDToEvaluate="txtAc count"
ErrorFormatter="Red Error Message (class: TextErrorFormatter)" ErrorMessage="Enter Member Number.">
<ErrorFormatterContainer>
<VAM:TextErrorFormatter Display="Dynamic" Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False" ForeColor="Red" Name="Red Error Message" />
</ErrorFormatterContainer>
</VAM:RequiredTextValidato r>
</span>
</td>
</tr>
<tr>
<td colspan="2" class="textalgnctr">
<asp:Button ID="btnCheckAccount" runat="server" Text="Check My Status" OnClick="btnCheckAccount_C lick" /></td>
</tr>
</table>
</form>
<asp:Panel ID="pnlExpired" runat="server" Visible="false">
<p><asp:Literal ID="txtFirstName" runat="server"></asp:Liter al>, it seems that your membership expired on <asp:Literal ID="txtDateExpire" runat="server"></asp:Liter al>. Renew now ></p>
</asp:Panel>
<asp:Panel ID="pnlActive" runat="server" Visible="false"><p> <asp:Literal ID="txtFirstNameActive" runat="server"></asp:Liter al>, you are an active: <asp:Literal ID="txtMemberType" runat="server"></asp:Liter al>.</p>
<asp:Panel ID="pnlSendEmail" runat="server" Visible="false">
<p>Did you need your password sent to your email address? If so, you may do so now:</p>
<p><asp:Button ID="btnSendEmail" runat="server" Text="Send My Password" /></p>
</asp:Panel>
</asp:Panel>
<asp:CheckBox ID="cbxActive" runat="server" Visible="false"/>
<asp:Panel ID="pnlNoRecords" runat="server" Visible="false">
<p> No Records Found. Please enter a valid Member Number.</p></asp:Panel>
<asp:Panel ID="pnlNotYetActive" runat="server" Visible="false">
<p>Be patient, you are not yet active.</p>
</asp:Panel>
</body>
</html>
I'm having a lot of trouble with this one.
A simple textbox control and a button control. If a visitor types a number into the textbox, and then clicks the 'submit' button with the mouse, the onclick event runs a subroutine that does a membership check. All is well.
However, if the person simply types their member number into the text box and presses ENTER, the page appears to post back but no data is processed.
Any idea what is going on? This is driving me NUTS!!
Here's the complete code. Any help would be appreciated.
<%@ Page Language="VB" EnableViewState="false" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Sql
<%@ Import Namespace="System.Configur
<%@ Register Assembly="PeterBlum.VAM" Namespace="PeterBlum.VAM" TagPrefix="VAM" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script runat="server">
Protected Sub btnCheckAccount_Click(ByVa
Dim MyConnection As SqlConnection
Dim MyCommand As SqlCommand
Dim MyReader As SqlDataReader
Dim IDParam As SqlParameter
Dim CheckIfActive As Boolean
Dim CheckEmailAddress As String
MyConnection = New SqlConnection(Configuratio
MyCommand = New SqlCommand()
MyCommand.CommandText = "SELECT * from vw_MemberStatusCheck WHERE Account = @ID"
MyCommand.CommandType = CommandType.Text
MyCommand.Connection = MyConnection
IDParam = New SqlParameter()
IDParam.ParameterName = "@ID"
IDParam.Value = txtAccount.Text
MyCommand.Parameters.Add(I
MyCommand.Connection.Open(
MyReader = MyCommand.ExecuteReader(Co
pnlNoRecords.Visible = True
pnlActive.Visible = False
pnlExpired.Visible = False
While MyReader.Read
txtDateExpire.Text = MyReader("DateExpire").ToS
txtFirstName.Text = MyReader("FirstName")
txtFirstNameActive.Text = MyReader("FirstName")
txtMemberType.Text = MyReader("MemberType")
cbxActive.Checked = MyReader("Active")
txtAccount.Text = MyReader("Account")
CheckIfActive = MyReader("InitialSuccessPm
CheckEmailAddress = MyReader("Email")
If cbxActive.Checked = True Then
pnlActive.Visible = True
pnlExpired.Visible = False
pnlNoRecords.Visible = False
Else
End If
If cbxActive.Checked = False Then
pnlExpired.Visible = True
pnlActive.Visible = False
pnlNoRecords.Visible = False
Else
End If
If CheckIfActive = True Then
pnlNotYetActive.Visible = True
pnlSendEmail.Visible = True
pnlExpired.Visible = False
pnlActive.Visible = False
pnlNoRecords.Visible = False
End If
End While
MyCommand.Dispose()
MyConnection.Dispose()
End Sub
</script><title>Forgot Your Password?</title>
<!--#include virtual="/assets/inc/cmn/h
<style type="text/css" media="all">
table.tablelistnb td.lbl{padding-right:0;}
table.tablelistnb{margin-b
#btnLogin{font-size:115%;f
input.errorbackground{back
#bkground{padding-bottom:7
</style>
<script type="text/JavaScript" src="/assets/js/popup.js">
</head>
<body id="twocol">
<h1 Membership Status</h1>
<p>Enter your Member Number in the box below to check your APDT Membership status.</p>
<form id="frmLogin" style="margin-bottom: 0.5em" runat="server">
<table border="0" cellpadding="0" cellspacing="0" class="tablelistnb">
<tr>
<td nowrap="nowrap" class="lbl" style="text-align:right"><
<td width="100%"><asp:TextBox ID="txtAccount" runat="server" Size="6" MaxLength="6" TabIndex="1" ToolTip="Type your APDT Membership Number in this box." /> <span class="small"><VAM:DataTyp
DataType="Integer" ErrorFormatter="Text (class: TextErrorFormatter)" ErrorMessage="Numbers only, please.">
<ErrorFormatterContainer>
<VAM:TextErrorFormatter Display="Dynamic" ForeColor="Red" />
</ErrorFormatterContainer>
</VAM:DataTypeCheckValidat
<VAM:RequiredTextValidator
ErrorFormatter="Red Error Message (class: TextErrorFormatter)" ErrorMessage="Enter Member Number.">
<ErrorFormatterContainer>
<VAM:TextErrorFormatter Display="Dynamic" Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False" ForeColor="Red" Name="Red Error Message" />
</ErrorFormatterContainer>
</VAM:RequiredTextValidato
</span>
</td>
</tr>
<tr>
<td colspan="2" class="textalgnctr">
<asp:Button ID="btnCheckAccount" runat="server" Text="Check My Status" OnClick="btnCheckAccount_C
</tr>
</table>
</form>
<asp:Panel ID="pnlExpired" runat="server" Visible="false">
<p><asp:Literal ID="txtFirstName" runat="server"></asp:Liter
</asp:Panel>
<asp:Panel ID="pnlActive" runat="server" Visible="false"><p> <asp:Literal ID="txtFirstNameActive" runat="server"></asp:Liter
<asp:Panel ID="pnlSendEmail" runat="server" Visible="false">
<p>Did you need your password sent to your email address? If so, you may do so now:</p>
<p><asp:Button ID="btnSendEmail" runat="server" Text="Send My Password" /></p>
</asp:Panel>
</asp:Panel>
<asp:CheckBox ID="cbxActive" runat="server" Visible="false"/>
<asp:Panel ID="pnlNoRecords" runat="server" Visible="false">
<p> No Records Found. Please enter a valid Member Number.</p></asp:Panel>
<asp:Panel ID="pnlNotYetActive" runat="server" Visible="false">
<p>Be patient, you are not yet active.</p>
</asp:Panel>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thank you. That's exactly what I was looking for. Problem solved!
Happy Programming!
Christopher