Ask a Question related to ASP.NET General, Design and Development.
-
Kathy Burke #1
Re: Problem on submit button
Justin,
As I posted earlier today, I have this same problem. UNLESS I put a
button on the page, my textchanged autopostback won't fire on ENTER
(will sometimes fire on TAB).
I have one textbox, no buttons, the textbox won't fire alone. Would you
have similar code to fix this? Right now, I've had to put a tiny button
on my page that does nothing but sit there to allow the textbox to be
functional. THIS JUST DOESN'T SEEM RIGHT. If I make the button
visible=false, the textbox no longer works.
IS THIS A BUG? Because the textbox set to autopostback=true does NOT
function as advertised.
Thanks.
Kathy
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Kathy Burke Guest
-
Submit button
I have a web form with a few text fields some validataion and a submit button. When I click the submit bittin the serverside event does not... -
Submit Button Problem
I’ve created a form and would like the form to be submitted using the HTML option. So far every time I’ve tested the form I get an Acrobat error... -
[PHP] using submit button and PHP-HELP
thanx for your help, Ive got flu and all these small things seem to be escaping my eyes. I just want to ask you a small question: If i want this... -
value submit button
You can get the button value use code below: <?php echo $_POST;?> <form method="post"> <input type="submit" name="submit" value="submit1">... -
Help with Submit button...
Hi, I have a graphic, I wanted to use it for a submit button. For some reason it does not work.. it acts more of a link. The problem with... -
Kathy Burke #2
Re: Problem on submit button
Sorry, just one more thing...since no one has answered my previous post
on this one.
On another page, I have an asp:textbox and an asp:button. The button
runs javascript to open a pop-up window. The textbox is supposed to run
textchanged sub when ENTER is pressed.
What happens is that the textbox event does fire, but so does the button
event EVERY TIME.
Any suggestions for correcting this?
Thanks again.
Kathy
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Kathy Burke Guest
-
Kevin Spencer #3
Re: Problem on submit button
The TextBox's "TextChanged" event isn't supposed to fire when the value in
it changes on the client. From the .Net SDK:
"Occurs when the content of the text box changes between posts to the
server."
This means that when the Page posts back, if the content of the textbox has
changed, this event will fire.
The client-side "onchange" event for a textbox fires whenever the value
changes in the textbox, and you don't want it to PostBack whenever THAT
happens. For example, on the client, if you were to type the string "Hello"
into a textbox, the "onchange" event would fire 5 times!
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
[url]http://www.takempis.com[/url]
Big things are made up of
lots of little things.
"Kathy Burke" <kathyburke40@attbi.com> wrote in message
news:uZA0k$VUDHA.656@tk2msftngp13.phx.gbl...> Justin,
>
> As I posted earlier today, I have this same problem. UNLESS I put a
> button on the page, my textchanged autopostback won't fire on ENTER
> (will sometimes fire on TAB).
>
> I have one textbox, no buttons, the textbox won't fire alone. Would you
> have similar code to fix this? Right now, I've had to put a tiny button
> on my page that does nothing but sit there to allow the textbox to be
> functional. THIS JUST DOESN'T SEEM RIGHT. If I make the button
> visible=false, the textbox no longer works.
>
> IS THIS A BUG? Because the textbox set to autopostback=true does NOT
> function as advertised.
>
> Thanks.
>
> Kathy
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
Kevin Spencer Guest
-
S. Justin Gengo #4
Re: Problem on submit button
Kathy,
The button is fired because it is the only one on the form. (I know you
already know this because you said you added a button to keep this from
happening.) This is not a .net behaviour. This is the way browsers are
designed. If a form only has one submit button in it the browser assumes
it's the default button and should be clicked when enter is pressed from
anywhere in the form.
The solution might depend on what you are doing with the button. If the
button isn't triggering an event server side you may be able to just switch
to an html button. Use a button set to type="button" instead of
type="submit" and it won't post back automatically on enter. You could even
use a javascript with form.submit() in it and the button would still post
back to the server if you need to submit the form.
But if you are running a server side event based on the button's submit then
you need to use some type .net control. Maybe you could use a link button
instead of a regular button. It wouldn't be exactly the same look, but a
link that says submit will still be pretty clear to the users. (A link
button wouldn't submit when enter is pressed from the text box.)
I hope one of these options solves your problem! :)
--
S. Justin Gengo, MCP
Web Developer
Free code library at:
[url]www.aboutfortunate.com[/url]
"Out of chaos comes order."
Nietzche
"Kathy Burke" <kathyburke40@attbi.com> wrote in message
news:O06Hl$VUDHA.656@tk2msftngp13.phx.gbl...> Sorry, just one more thing...since no one has answered my previous post
> on this one.
>
> On another page, I have an asp:textbox and an asp:button. The button
> runs javascript to open a pop-up window. The textbox is supposed to run
> textchanged sub when ENTER is pressed.
>
> What happens is that the textbox event does fire, but so does the button
> event EVERY TIME.
>
> Any suggestions for correcting this?
>
> Thanks again.
>
> Kathy
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
S. Justin Gengo Guest
-
Kathy Burke #5
Re: Problem on submit button
Thanks again, Justin, that IS making it a bit clearer.
I have a page WITHOUT a submit button, just a textbox. From the SDK doc,
my understanding is that if you create an asp:textbox control WITH
AutoPostBack = True, then on ENTER it should do the _DOPOSTBACK from the
html code (I DO see this in the html source.
But without that button somewhere on the page, the _DOPOSTBACK on the
ENTER event doesn't fire.
Am I just being stupid? You're explanation was great, just still
wondering how to move forward.
On the page where I have the same textbox but I DO have a button that
runs a javascript popup window, every time I hit ENTER (aka Submit) it
also opens up the popup window from the button. Any suggestions on how
to stop that?
Again, really appreciate your time.
Kathy
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Kathy Burke Guest
-
S. Justin Gengo #6
Re: Problem on submit button
Kathy,
Now I understand what you're trying to do!
I took a look at the documentation and here's an exact quote about the
autopostback of a text box: "Gets or sets a value indicating whether an
automatic postback to the server will occur whenever the user modifies the
text in the TextBox control and then tabs out of the control."
Notice that it says: "...and then tabs..."
But now I'm really confused becuase I just created a blank web form with a
single text box on it and sure enough when I tab out of the control the form
posts back to the server. And it posts back when I hit the enter key also!
So now I don't know why yours doesn't.
I'm using v1.1 of the .net framework and Visual Studio.Net 2003 are you
using the same?
--
S. Justin Gengo, MCP
Web Developer
Free code library at:
[url]www.aboutfortunate.com[/url]
"Out of chaos comes order."
Nietzche
"Kathy Burke" <kathyburke40@attbi.com> wrote in message
news:uRSMtMeUDHA.2004@TK2MSFTNGP10.phx.gbl...> Thanks again, Justin, that IS making it a bit clearer.
>
> I have a page WITHOUT a submit button, just a textbox. From the SDK doc,
> my understanding is that if you create an asp:textbox control WITH
> AutoPostBack = True, then on ENTER it should do the _DOPOSTBACK from the
> html code (I DO see this in the html source.
>
> But without that button somewhere on the page, the _DOPOSTBACK on the
> ENTER event doesn't fire.
>
> Am I just being stupid? You're explanation was great, just still
> wondering how to move forward.
>
> On the page where I have the same textbox but I DO have a button that
> runs a javascript popup window, every time I hit ENTER (aka Submit) it
> also opens up the popup window from the button. Any suggestions on how
> to stop that?
>
> Again, really appreciate your time.
>
> Kathy
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
S. Justin Gengo Guest
-
S. Justin Gengo #7
Re: Problem on submit button
Kathy,
I think you need to solve the text box post back problem. If you do I think
that then solves both of your problems. As I've discovered my text box does
an auto post back just like it's supposed to and it does so without any
button on the page.
If you solve that then you'll be able to use a different type of button on
your form where you are opening a new window and both problems will be
solved.
Could you post your code? If I had your code to test perhaps I could
discover what's wrong.
--
S. Justin Gengo, MCP
Web Developer
Free code library at:
[url]www.aboutfortunate.com[/url]
"Out of chaos comes order."
Nietzche
"KathyB" <KathyBurke40@attbi.com> wrote in message
news:75e8d381.0307240928.75ff8ad8@posting.google.c om...news:<#yHUqmeUDHA.3312@tk2msftngp13.phx.gbl>...> Yes, .net 1.1 and vs.net 2003. It's actually a very simple page with
> some labels and that one textbox...I've put a teeny tiny submit button
> on it to that when Enter is pressed, it does fire the textchanged
> event on postback.
>
> Any clue as to my other problem? The page with a textbox AND a button
> to open a new window. The button event fires every time I hit ENTER in
> the textbox. I realize now (from your earlier explanation) that it is
> form design...could you suggest how to work around it? When I tried
> using an html button instead, my textbox ENTER wouldn't fire the
> postback...because of course it was then only html code?
>
> Anyway, thank you again for everything.
>
> Kathy
> *******
>
> "S. Justin Gengo" <sjgengo@aboutfortunate.com> wrote in messagethe> > Kathy,
> >
> > Now I understand what you're trying to do!
> >
> > I took a look at the documentation and here's an exact quote about the
> > autopostback of a text box: "Gets or sets a value indicating whether an
> > automatic postback to the server will occur whenever the user modifieswith a> > text in the TextBox control and then tabs out of the control."
> >
> > Notice that it says: "...and then tabs..."
> >
> > But now I'm really confused becuase I just created a blank web formform> > single text box on it and sure enough when I tab out of the control thealso!> > posts back to the server. And it posts back when I hit the enter keydoc,> >
> > So now I don't know why yours doesn't.
> >
> > I'm using v1.1 of the .net framework and Visual Studio.Net 2003 are you
> > using the same?
> >
> >
> > --
> > S. Justin Gengo, MCP
> > Web Developer
> >
> > Free code library at:
> > [url]www.aboutfortunate.com[/url]
> >
> > "Out of chaos comes order."
> > Nietzche
> > "Kathy Burke" <kathyburke40@attbi.com> wrote in message
> > news:uRSMtMeUDHA.2004@TK2MSFTNGP10.phx.gbl...> > > Thanks again, Justin, that IS making it a bit clearer.
> > >
> > > I have a page WITHOUT a submit button, just a textbox. From the SDKthe> > > my understanding is that if you create an asp:textbox control WITH
> > > AutoPostBack = True, then on ENTER it should do the _DOPOSTBACK from> > > html code (I DO see this in the html source.
> > >
> > > But without that button somewhere on the page, the _DOPOSTBACK on the
> > > ENTER event doesn't fire.
> > >
> > > Am I just being stupid? You're explanation was great, just still
> > > wondering how to move forward.
> > >
> > > On the page where I have the same textbox but I DO have a button that
> > > runs a javascript popup window, every time I hit ENTER (aka Submit) it
> > > also opens up the popup window from the button. Any suggestions on how
> > > to stop that?
> > >
> > > Again, really appreciate your time.
> > >
> > > Kathy
> > >
> > > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> > > Don't just participate in USENET...get rewarded for it!
S. Justin Gengo Guest
-
Kathy Burke #8
Re: Problem on submit button
Justin, you're right, if I (aka "we"?) could solve this it would make my
life much easier going forward.
Thank you for all the help...Kathy
Here is my aspx.vb code. It is the page where I have a textbox with
TextChanged event that I need to run on ENTER and a button to open a
popup window (which currently fires every time ENTER is pressed in the
textbox...I've included the html at the end.
**************************
Option Explicit On
Imports System
Imports System.IO
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.UI.WebControls
Imports System.Web.UI.AttributeCollection
Imports System.Xml
Public Class Birth2
Inherits System.Web.UI.Page
Protected WithEvents lblStation As System.Web.UI.WebControls.Label
Protected WithEvents lblUser As System.Web.UI.WebControls.Label
Protected WithEvents txtStart As System.Web.UI.WebControls.TextBox
Protected WithEvents lblStart As System.Web.UI.WebControls.Label
Protected WithEvents lblFinish As System.Web.UI.WebControls.Label
Protected WithEvents lblScan As System.Web.UI.WebControls.Label
Protected WithEvents txtScan As System.Web.UI.WebControls.TextBox
Protected WithEvents lblScanned As System.Web.UI.WebControls.Label
Protected WithEvents lblStation_label As
System.Web.UI.WebControls.Label
Protected WithEvents lbl_User As System.Web.UI.WebControls.Label
Protected WithEvents lbl_Cust As System.Web.UI.WebControls.Label
Protected WithEvents lblCust As System.Web.UI.WebControls.Label
Protected WithEvents lbl_WO As System.Web.UI.WebControls.Label
Protected WithEvents lblAssy As System.Web.UI.WebControls.Label
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents lblWO As System.Web.UI.WebControls.Label
Protected WithEvents lblQty As System.Web.UI.WebControls.Label
Protected WithEvents lbl_Qty As System.Web.UI.WebControls.Label
Protected WithEvents txtFinish As System.Web.UI.WebControls.TextBox
Protected WithEvents lblMsg As System.Web.UI.WebControls.Label
Protected WithEvents txtCount As System.Web.UI.WebControls.TextBox
Protected WithEvents btnList As System.Web.UI.WebControls.Button
Dim strConn As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=" & Server.mappath("WI_TEST.mdb") & ";"
#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()
'set the onclick event for the btnList button
btnList.Attributes.Add("onclick", "pop_window();return false;")
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
If Not IsPostBack Then
Dim varStation As String = Session("Station")
Dim varUser As String = Session("UserName")
Dim varAssy As String = Session("Assy")
Dim varCust As String = Session("Cust")
Dim varWO As String = Session("WO")
Dim varQty As String = Session("Qty")
Dim varWF As String = Session("WF")
Me.lblStation.Text = varStation
Me.lblUser.Text = varUser
Me.lblCust.Text = varCust
Me.lblAssy.Text = varAssy
Me.lblWO.Text = varWO
Me.lblQty.Text = varQty
'Get Start and Finish times if exist - set via hidden_birth
and hidden_birth2 pages
Dim varStartTime As String = Session("StartTime")
Dim varFinishTime As String = Session("FinishTime")
If Session("StartTime") Is Nothing Then
txtStart.Text = ""
Else
txtStart.Text = varStartTime
End If
If Session("FinishTime") Is Nothing Then
txtFinish.Text = ""
Else
txtFinish.Text = varFinishTime
'process if Finish button has been clicked prior to this
page load
If txtFinish.Text <> "" Then
'add Finish DateTime to all <Board> elements in this
station
varWF = Session("WF")
Dim varFinish As String = Session("Finish")
Dim xDoc As New XmlDocument()
xDoc.LoadXml(varWF)
Dim NodeList As XmlNodeList =
xDoc.SelectNodes("/WorkFlow/Assembly/Station[@name='Label']/WI[@order='1
']/Boards/Board")
'create and append the new attributes
Dim node As XmlElement
For Each node In NodeList
node.SetAttribute("finish", varFinish)
node.SetAttribute("finishuser", varUser)
Next
Dim xDoc1 As New XmlDocument()
xDoc1.LoadXml(varWF)
Dim nodelist1 As XmlNodeList =
xDoc1.SelectNodes("/WorkFlow/Assembly/Station[@name='Label']/WI[@order='
1']/Boards/Board")
Dim varTestCount As String = xDoc1.ChildNodes.Count
'Save as xml string and recreate Session variable
Dim strWF As String = xDoc.OuterXml
Session("WF") = strWF
'update xmlWF field in database
strWF = Session("WF")
Dim Conn As New OleDbConnection()
Dim Adapter As OleDbDataAdapter
Dim Cmd1 As OleDbCommand
Dim strSQL1 As String
strSQL1 = "UPDATE tblWorkOrders SET xmlWF='" & strWF
& "' WHERE WorkOrder= '" & varWO & "'"
Conn = New OleDbConnection(strConn)
Cmd1 = New OleDbCommand(strSQL1, Conn)
Conn.Open()
Cmd1.ExecuteNonQuery()
Conn.Close()
txtScan.Enabled = False
Response.Write("<script>parent.right.location='pos tWI.aspx'</script>")
End If
End If
SetFocus(Me.txtScan)
Else
SetFocus(Me.txtScan)
'user message if scans equal quantity and disable txtScan
control
Dim varCount As String = Session("Count")
Dim varQty As String = Session("Qty")
varCount = Session("Count")
If varCount = varQty Then
lblMsg.Text = "Total scans equal the work order
quantity. Please click FINISH in the work instruction."
txtScan.Enabled = False
End If
End If
End Sub
Private Sub SetFocus(ByVal ctrl As System.Web.UI.Control)
Dim s As String = "<SCRIPT
language='javascript'>document.getElementById('" & ctrl.ID & "').focus()
</SCRIPT>"
RegisterStartupScript("focus", s)
End Sub
Private Sub txtScan_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles txtScan.TextChanged
If txtStart.Text = "" Then
lblMsg.Text = "You must first click START in the work
instruction before scanning the serial numbers."
txtScan.Text = ""
Exit Sub
End If
Dim varStation As String = Session("Station")
Dim varUser As String = Session("UserName")
Dim varWO As String = Session("WO")
Dim varQty As String = Session("Qty")
Dim varSN As String = txtScan.Text
Dim varStart As String = Session("Start") 'date and time for
xmlWF
Dim varStartTime As String = Session("StartTime") 'format for
time only txtStart
Dim varCount As String = Session("Count")
Dim varWF As String = Session("WF")
'check to see if serial number already exists in tblSerialNo
Dim Conn As New OleDbConnection()
Dim Rdr As OleDbDataReader
Dim strSQL As String = "SELECT SerialNo FROM tblSerialNo WHERE
SerialNo = '" & varSN & "'"
Dim Cmd As New OleDbCommand(strSQL, Conn)
Conn = New OleDbConnection(strConn)
Cmd.Connection = Conn
Conn.Open()
Rdr = Cmd.ExecuteReader()
If Rdr.Read() Then
lblMsg.Text = "This serial number has already been entered.
Please try again or contact your supervisor."
Rdr.Close()
Conn.Close()
txtScan.Text = ""
SetFocus(Me.txtScan)
Exit Sub
Else
Rdr.Close()
Conn.Close()
'insert new serial number into tblSerialNo
Dim strSQL3 As String
strSQL3 = "INSERT INTO tblSerialNo (WorkOrder, SerialNo)
VALUES ('" & varWO & "', '" & varSN & "')"
Dim Cmd3 As New OleDbCommand(strSQL3, Conn)
Conn.Open()
Cmd3.ExecuteNonQuery()
Conn.Close()
'load the tblWorkOrders.xmlWF string as an xmlDoc and create
the new <board> element
'with serial number, start and user attributes
Dim xDoc As New XmlDocument()
xDoc.LoadXml(varWF) 'load from variable
Dim xElem As XmlElement =
xDoc.SelectSingleNode("//Station[@name='Label']/WI[@order='1']/Boards")
Dim elem = xDoc.CreateElement("Board")
elem.SetAttribute("sn", varSN)
elem.SetAttribute("start", varStart)
elem.SetAttribute("startuser", varUser)
xElem.AppendChild(elem)
'Get count of <Board> nodes for txtCount control
txtCount.Text = xElem.ChildNodes.Count
'Set session variable to compare to varQty
Session("Count") = txtCount.Text
'Save WF as xml string and recreate session variable
Dim strWF As String = xDoc.OuterXml
Session("WF") = strWF
'update xmlWF field in database
Dim Adapter As OleDbDataAdapter
Dim Cmd1 As OleDbCommand
Dim strSQL1 As String
strSQL1 = "UPDATE tblWorkOrders SET xmlWF='" & strWF & "'
WHERE WorkOrder= '" & varWO & "'"
Conn = New OleDbConnection(strConn)
Cmd1 = New OleDbCommand(strSQL1, Conn)
Conn.Open()
Cmd1.ExecuteNonQuery()
Conn.Close()
'clear the txtScan textbox
txtScan.Text = ""
'user message if scans equal quantity and disable txtScan
control
varCount = Session("Count")
If varCount = varQty Then
lblMsg.Text = "Total scans equal the work order
quantity. Please click FINISH in the work instruction."
txtScan.Enabled = False
End If
End If
End Sub
End Class
********************
HTML***************
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Birth2.aspx.vb" Inherits="OWI_NextGen.Birth2"
EnableViewState="True"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Status</title>
<script language="javascript">
function pop_window()
{
var confirmWin = null;
confirmWin = window.open('Scanned.aspx', 'SerialNumbers',
'width=300,height=400,left=200,top=200,toolbar=no, resizable=no,menubar=n
o');
}
</script>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body bgColor="#330099" MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:label id="lblScanned" style="Z-INDEX: 111; LEFT: 80px; POSITION:
absolute; TOP: 341px" runat="server" Width="47px" ForeColor="Cyan"
Height="15px" Font-Bold="True" Font-Size="X-Small" Font-Names="Gill Sans
MT">Scanned</asp:label><asp:label id="lblMsg" style="Z-INDEX: 122; LEFT:
23px; POSITION: absolute; TOP: 436px" runat="server" Width="251px"
ForeColor="Yellow" Height="76px" Font-Bold="True" Font-Size="Small"
Font-Names="Gill Sans MT"></asp:label><asp:label id="lbl_Qty"
style="Z-INDEX: 121; LEFT: 7px; POSITION: absolute; TOP: 132px"
runat="server" Width="70px" ForeColor="White" Font-Bold="True"
Font-Names="Gill Sans MT">Quantity:</asp:label><asp:label id="lblQty"
style="Z-INDEX: 119; LEFT: 114px; POSITION: absolute; TOP: 132px"
runat="server" ForeColor="Yellow" Font-Bold="True" Font-Names="Gill Sans
MT"></asp:label><asp:label id="lblWO" style="Z-INDEX: 120; LEFT: 114px;
POSITION: absolute; TOP: 110px" runat="server" ForeColor="Yellow"
Font-Bold="True" Font-Names="Gill Sans MT"></asp:label><asp:label
id="Label1" style="Z-INDEX: 115; LEFT: 7px; POSITION: absolute; TOP:
88px" runat="server" Width="70px" ForeColor="White" Font-Bold="True"
Font-Names="Gill Sans MT">Assembly:</asp:label><asp:label id="lblAssy"
style="Z-INDEX: 118; LEFT: 114px; POSITION: absolute; TOP: 88px"
runat="server" Width="183px" ForeColor="Yellow" Font-Bold="True"
Font-Names="Gill Sans MT"></asp:label><asp:label id="lbl_WO"
style="Z-INDEX: 116; LEFT: 7px; POSITION: absolute; TOP: 110px"
runat="server" Width="101px" ForeColor="White" Font-Bold="True"
Font-Names="Gill Sans MT">Work Order:</asp:label><asp:label id="lblCust"
style="Z-INDEX: 117; LEFT: 114px; POSITION: absolute; TOP: 66px"
runat="server" ForeColor="Yellow" Font-Bold="True" Font-Names="Gill Sans
MT"></asp:label><asp:label id="lbl_Cust" style="Z-INDEX: 114; LEFT: 7px;
POSITION: absolute; TOP: 66px" runat="server" Width="70px"
ForeColor="White" Font-Bold="True" Font-Names="Gill Sans
MT">Customer:</asp:label><asp:label id="lbl_User" style="Z-INDEX: 113;
LEFT: 7px; POSITION: absolute; TOP: 34px" runat="server" Width="70px"
ForeColor="Yellow" Font-Bold="True" Font-Names="Gill Sans
MT">User:</asp:label><asp:label id="lblStation_label" style="Z-INDEX:
112; LEFT: 7px; POSITION: absolute; TOP: 15px" runat="server"
Width="70px" ForeColor="Yellow" Font-Bold="True" Font-Names="Gill Sans
MT">Station:</asp:label><asp:textbox id="txtFinish" style="Z-INDEX: 104;
LEFT: 141px; POSITION: absolute; TOP: 214px" runat="server" Width="71px"
Font-Size="XX-Small" BackColor="Silver"
ReadOnly="True"></asp:textbox><asp:label id="lblScan" style="Z-INDEX:
109; LEFT: 54px; POSITION: absolute; TOP: 265px" runat="server"
Width="169px" ForeColor="Yellow" Height="23px" Font-Bold="True"
Font-Size="Small" Font-Names="Gill Sans MT">Scan Serial
Number(s)</asp:label><asp:textbox id="txtScan" style="Z-INDEX: 108;
LEFT: 63px; POSITION: absolute; TOP: 293px" runat="server" Width="144px"
AutoPostBack="True"></asp:textbox><asp:label id="lblFinish"
style="Z-INDEX: 107; LEFT: 159px; POSITION: absolute; TOP: 194px"
runat="server" Width="47px" ForeColor="Cyan" Height="15px"
Font-Bold="True" Font-Size="X-Small" Font-Names="Gill Sans
MT">Finish</asp:label><asp:label id="lblStart" style="Z-INDEX: 106;
LEFT: 82px; POSITION: absolute; TOP: 194px" runat="server" Width="47px"
ForeColor="Cyan" Height="15px" Font-Bold="True" Font-Size="X-Small"
Font-Names="Gill Sans MT">Start</asp:label><asp:textbox id="txtCount"
style="Z-INDEX: 105; LEFT: 143px; POSITION: absolute; TOP: 339px"
runat="server" Width="43px"
BackColor="Silver"></asp:textbox><asp:textbox id="txtStart"
style="Z-INDEX: 103; LEFT: 60px; POSITION: absolute; TOP: 214px"
runat="server" Width="71px" Font-Size="XX-Small" BackColor="Silver"
ReadOnly="True"></asp:textbox><asp:label id="lblStation" style="Z-INDEX:
101; LEFT: 114px; POSITION: absolute; TOP: 14px" runat="server"
ForeColor="White" Font-Bold="True" Font-Names="Gill Sans
MT"></asp:label><asp:label id="lblUser" style="Z-INDEX: 102; LEFT:
114px; POSITION: absolute; TOP: 35px" runat="server" ForeColor="White"
Font-Bold="True" Font-Names="Gill Sans MT"></asp:label>
<HR style="Z-INDEX: 110; LEFT: 6px; POSITION: absolute; TOP: 168px;
HEIGHT: 5px" width="100%" color="#ff0000" SIZE="5">
<asp:Button id="btnList" style="Z-INDEX: 124; LEFT: 73px; POSITION:
absolute; TOP: 389px" runat="server" Width="127px" Height="30px"
Text="Show List Scanned"></asp:Button></form>
</body>
</HTML>
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Kathy Burke Guest
-
S. Justin Gengo #9
Re: Problem on submit button
Kathy,
Thanks for posting the code. That helped a lot.
First of all the reason the button that opens the popup window is still
causing a post back is pretty simple. You just have to change the attribute
you're adding from:
btnList.Attributes.Add("onclick", "pop_window();return false;")
to:
btnList.Attributes.Add("onclick", "javascript:pop_window();return false;")
Now it doesn't post back when clicked, but it creates another problem. Now
the text box doesn't post back.
But I've solved that also.
The text box's autopostback works as advertised. It will post back if the
text inside it is changed from whatever it was when the form was entered and
then it's tabbed out of. (I know this isn't what you desire. Here are two
choices:
1) If you want the text box to submit the form when the enter key is pressed
no matter whether the text in it was changed or not then:
Set it's autopostback attribute to False
and use this exact code:
txtScan.Attributes.Add("onkeydown", "javascript:if((event.which &&
event.which == 13) || (event.keyCode && event.keyCode ==
13)){form.submit();return false;}else return true;")
(It won't post back when tabbed this way though.)
You'll note that this code is just submitting the form. You'll probably
have to examine the
text box each time in the page load event to see what text is in it
because the text
changed event won't fire this way.
2) If you still want the text box to submit when tabbed and only if the text
has been changed then:
Set it's autopostback attribute to True
and use this exact code:
txtScan.Attributes.Add("onkeydown", "javascript:if((event.which &&
event.which == 13) || (event.keyCode && event.keyCode ==
13)){__doPostBack('txtScan','');return false;}else return true;")
This way you could still use the text changed event in your codebehind
page.
--
S. Justin Gengo, MCP
Web Developer
Free code library at:
[url]www.aboutfortunate.com[/url]
"Out of chaos comes order."
Nietzche
"Kathy Burke" <kathyburke40@attbi.com> wrote in message
news:OrDdaprUDHA.1812@TK2MSFTNGP11.phx.gbl...> Justin, you're right, if I (aka "we"?) could solve this it would make my
> life much easier going forward.
>
> Thank you for all the help...Kathy
>
> Here is my aspx.vb code. It is the page where I have a textbox with
> TextChanged event that I need to run on ENTER and a button to open a
> popup window (which currently fires every time ENTER is pressed in the
> textbox...I've included the html at the end.
>
> **************************
> Option Explicit On
>
> Imports System
> Imports System.IO
> Imports System.Data
> Imports System.Data.OleDb
> Imports System.Web.UI.WebControls
> Imports System.Web.UI.AttributeCollection
> Imports System.Xml
>
> Public Class Birth2
> Inherits System.Web.UI.Page
> Protected WithEvents lblStation As System.Web.UI.WebControls.Label
> Protected WithEvents lblUser As System.Web.UI.WebControls.Label
> Protected WithEvents txtStart As System.Web.UI.WebControls.TextBox
> Protected WithEvents lblStart As System.Web.UI.WebControls.Label
> Protected WithEvents lblFinish As System.Web.UI.WebControls.Label
> Protected WithEvents lblScan As System.Web.UI.WebControls.Label
> Protected WithEvents txtScan As System.Web.UI.WebControls.TextBox
> Protected WithEvents lblScanned As System.Web.UI.WebControls.Label
> Protected WithEvents lblStation_label As
> System.Web.UI.WebControls.Label
> Protected WithEvents lbl_User As System.Web.UI.WebControls.Label
> Protected WithEvents lbl_Cust As System.Web.UI.WebControls.Label
> Protected WithEvents lblCust As System.Web.UI.WebControls.Label
> Protected WithEvents lbl_WO As System.Web.UI.WebControls.Label
> Protected WithEvents lblAssy As System.Web.UI.WebControls.Label
> Protected WithEvents Label1 As System.Web.UI.WebControls.Label
> Protected WithEvents lblWO As System.Web.UI.WebControls.Label
> Protected WithEvents lblQty As System.Web.UI.WebControls.Label
> Protected WithEvents lbl_Qty As System.Web.UI.WebControls.Label
> Protected WithEvents txtFinish As System.Web.UI.WebControls.TextBox
> Protected WithEvents lblMsg As System.Web.UI.WebControls.Label
> Protected WithEvents txtCount As System.Web.UI.WebControls.TextBox
> Protected WithEvents btnList As System.Web.UI.WebControls.Button
>
> Dim strConn As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
> SOURCE=" & Server.mappath("WI_TEST.mdb") & ";"
>
> #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()
> 'set the onclick event for the btnList button
> btnList.Attributes.Add("onclick", "pop_window();return false;")
> 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
>
> If Not IsPostBack Then
>
> Dim varStation As String = Session("Station")
> Dim varUser As String = Session("UserName")
> Dim varAssy As String = Session("Assy")
> Dim varCust As String = Session("Cust")
> Dim varWO As String = Session("WO")
> Dim varQty As String = Session("Qty")
> Dim varWF As String = Session("WF")
> Me.lblStation.Text = varStation
> Me.lblUser.Text = varUser
> Me.lblCust.Text = varCust
> Me.lblAssy.Text = varAssy
> Me.lblWO.Text = varWO
> Me.lblQty.Text = varQty
>
> 'Get Start and Finish times if exist - set via hidden_birth
> and hidden_birth2 pages
> Dim varStartTime As String = Session("StartTime")
> Dim varFinishTime As String = Session("FinishTime")
>
> If Session("StartTime") Is Nothing Then
> txtStart.Text = ""
> Else
> txtStart.Text = varStartTime
> End If
>
> If Session("FinishTime") Is Nothing Then
> txtFinish.Text = ""
> Else
> txtFinish.Text = varFinishTime
>
> 'process if Finish button has been clicked prior to this
> page load
> If txtFinish.Text <> "" Then
> 'add Finish DateTime to all <Board> elements in this
> station
> varWF = Session("WF")
> Dim varFinish As String = Session("Finish")
> Dim xDoc As New XmlDocument()
> xDoc.LoadXml(varWF)
> Dim NodeList As XmlNodeList =
> xDoc.SelectNodes("/WorkFlow/Assembly/Station[@name='Label']/WI[@order='1
> ']/Boards/Board")
> 'create and append the new attributes
> Dim node As XmlElement
> For Each node In NodeList
> node.SetAttribute("finish", varFinish)
> node.SetAttribute("finishuser", varUser)
> Next
> Dim xDoc1 As New XmlDocument()
> xDoc1.LoadXml(varWF)
> Dim nodelist1 As XmlNodeList =
> xDoc1.SelectNodes("/WorkFlow/Assembly/Station[@name='Label']/WI[@order='
> 1']/Boards/Board")
> Dim varTestCount As String = xDoc1.ChildNodes.Count
>
> 'Save as xml string and recreate Session variable
> Dim strWF As String = xDoc.OuterXml
> Session("WF") = strWF
>
> 'update xmlWF field in database
> strWF = Session("WF")
> Dim Conn As New OleDbConnection()
> Dim Adapter As OleDbDataAdapter
> Dim Cmd1 As OleDbCommand
> Dim strSQL1 As String
> strSQL1 = "UPDATE tblWorkOrders SET xmlWF='" & strWF
> & "' WHERE WorkOrder= '" & varWO & "'"
> Conn = New OleDbConnection(strConn)
> Cmd1 = New OleDbCommand(strSQL1, Conn)
> Conn.Open()
> Cmd1.ExecuteNonQuery()
> Conn.Close()
>
> txtScan.Enabled = False
>
>
> Response.Write("<script>parent.right.location='pos tWI.aspx'</script>")
>
> End If
> End If
>
> SetFocus(Me.txtScan)
> Else
> SetFocus(Me.txtScan)
>
> 'user message if scans equal quantity and disable txtScan
> control
> Dim varCount As String = Session("Count")
> Dim varQty As String = Session("Qty")
> varCount = Session("Count")
> If varCount = varQty Then
> lblMsg.Text = "Total scans equal the work order
> quantity. Please click FINISH in the work instruction."
> txtScan.Enabled = False
> End If
>
> End If
> End Sub
>
>
>
> Private Sub SetFocus(ByVal ctrl As System.Web.UI.Control)
> Dim s As String = "<SCRIPT
> language='javascript'>document.getElementById('" & ctrl.ID & "').focus()
> </SCRIPT>"
> RegisterStartupScript("focus", s)
> End Sub
>
> Private Sub txtScan_TextChanged(ByVal sender As System.Object, ByVal
> e As System.EventArgs) Handles txtScan.TextChanged
> If txtStart.Text = "" Then
> lblMsg.Text = "You must first click START in the work
> instruction before scanning the serial numbers."
> txtScan.Text = ""
> Exit Sub
> End If
>
> Dim varStation As String = Session("Station")
> Dim varUser As String = Session("UserName")
> Dim varWO As String = Session("WO")
> Dim varQty As String = Session("Qty")
> Dim varSN As String = txtScan.Text
> Dim varStart As String = Session("Start") 'date and time for
> xmlWF
> Dim varStartTime As String = Session("StartTime") 'format for
> time only txtStart
> Dim varCount As String = Session("Count")
> Dim varWF As String = Session("WF")
>
> 'check to see if serial number already exists in tblSerialNo
> Dim Conn As New OleDbConnection()
> Dim Rdr As OleDbDataReader
> Dim strSQL As String = "SELECT SerialNo FROM tblSerialNo WHERE
> SerialNo = '" & varSN & "'"
> Dim Cmd As New OleDbCommand(strSQL, Conn)
> Conn = New OleDbConnection(strConn)
> Cmd.Connection = Conn
> Conn.Open()
> Rdr = Cmd.ExecuteReader()
> If Rdr.Read() Then
> lblMsg.Text = "This serial number has already been entered.
> Please try again or contact your supervisor."
> Rdr.Close()
> Conn.Close()
> txtScan.Text = ""
> SetFocus(Me.txtScan)
> Exit Sub
> Else
> Rdr.Close()
> Conn.Close()
> 'insert new serial number into tblSerialNo
> Dim strSQL3 As String
> strSQL3 = "INSERT INTO tblSerialNo (WorkOrder, SerialNo)
> VALUES ('" & varWO & "', '" & varSN & "')"
> Dim Cmd3 As New OleDbCommand(strSQL3, Conn)
> Conn.Open()
> Cmd3.ExecuteNonQuery()
> Conn.Close()
>
> 'load the tblWorkOrders.xmlWF string as an xmlDoc and create
> the new <board> element
> 'with serial number, start and user attributes
> Dim xDoc As New XmlDocument()
> xDoc.LoadXml(varWF) 'load from variable
> Dim xElem As XmlElement =
> xDoc.SelectSingleNode("//Station[@name='Label']/WI[@order='1']/Boards")
> Dim elem = xDoc.CreateElement("Board")
> elem.SetAttribute("sn", varSN)
> elem.SetAttribute("start", varStart)
> elem.SetAttribute("startuser", varUser)
> xElem.AppendChild(elem)
> 'Get count of <Board> nodes for txtCount control
> txtCount.Text = xElem.ChildNodes.Count
> 'Set session variable to compare to varQty
> Session("Count") = txtCount.Text
>
> 'Save WF as xml string and recreate session variable
> Dim strWF As String = xDoc.OuterXml
> Session("WF") = strWF
>
> 'update xmlWF field in database
> Dim Adapter As OleDbDataAdapter
> Dim Cmd1 As OleDbCommand
> Dim strSQL1 As String
> strSQL1 = "UPDATE tblWorkOrders SET xmlWF='" & strWF & "'
> WHERE WorkOrder= '" & varWO & "'"
> Conn = New OleDbConnection(strConn)
> Cmd1 = New OleDbCommand(strSQL1, Conn)
> Conn.Open()
> Cmd1.ExecuteNonQuery()
> Conn.Close()
>
> 'clear the txtScan textbox
> txtScan.Text = ""
>
> 'user message if scans equal quantity and disable txtScan
> control
> varCount = Session("Count")
> If varCount = varQty Then
> lblMsg.Text = "Total scans equal the work order
> quantity. Please click FINISH in the work instruction."
> txtScan.Enabled = False
> End If
>
> End If
>
> End Sub
>
> End Class
> ********************
>
> HTML***************
> <%@ Page Language="vb" AutoEventWireup="false"
> Codebehind="Birth2.aspx.vb" Inherits="OWI_NextGen.Birth2"
> EnableViewState="True"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <title>Status</title>
> <script language="javascript">
> function pop_window()
> {
> var confirmWin = null;
> confirmWin = window.open('Scanned.aspx', 'SerialNumbers',
> 'width=300,height=400,left=200,top=200,toolbar=no, resizable=no,menubar=n
> o');
> }
> </script>
> <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
> <meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
> <meta content="JavaScript" name="vs_defaultClientScript">
> <meta content="http://schemas.microsoft.com/intellisense/ie5"
> name="vs_targetSchema">
> </HEAD>
> <body bgColor="#330099" MS_POSITIONING="GridLayout">
> <form id="Form1" method="post" runat="server">
> <asp:label id="lblScanned" style="Z-INDEX: 111; LEFT: 80px; POSITION:
> absolute; TOP: 341px" runat="server" Width="47px" ForeColor="Cyan"
> Height="15px" Font-Bold="True" Font-Size="X-Small" Font-Names="Gill Sans
> MT">Scanned</asp:label><asp:label id="lblMsg" style="Z-INDEX: 122; LEFT:
> 23px; POSITION: absolute; TOP: 436px" runat="server" Width="251px"
> ForeColor="Yellow" Height="76px" Font-Bold="True" Font-Size="Small"
> Font-Names="Gill Sans MT"></asp:label><asp:label id="lbl_Qty"
> style="Z-INDEX: 121; LEFT: 7px; POSITION: absolute; TOP: 132px"
> runat="server" Width="70px" ForeColor="White" Font-Bold="True"
> Font-Names="Gill Sans MT">Quantity:</asp:label><asp:label id="lblQty"
> style="Z-INDEX: 119; LEFT: 114px; POSITION: absolute; TOP: 132px"
> runat="server" ForeColor="Yellow" Font-Bold="True" Font-Names="Gill Sans
> MT"></asp:label><asp:label id="lblWO" style="Z-INDEX: 120; LEFT: 114px;
> POSITION: absolute; TOP: 110px" runat="server" ForeColor="Yellow"
> Font-Bold="True" Font-Names="Gill Sans MT"></asp:label><asp:label
> id="Label1" style="Z-INDEX: 115; LEFT: 7px; POSITION: absolute; TOP:
> 88px" runat="server" Width="70px" ForeColor="White" Font-Bold="True"
> Font-Names="Gill Sans MT">Assembly:</asp:label><asp:label id="lblAssy"
> style="Z-INDEX: 118; LEFT: 114px; POSITION: absolute; TOP: 88px"
> runat="server" Width="183px" ForeColor="Yellow" Font-Bold="True"
> Font-Names="Gill Sans MT"></asp:label><asp:label id="lbl_WO"
> style="Z-INDEX: 116; LEFT: 7px; POSITION: absolute; TOP: 110px"
> runat="server" Width="101px" ForeColor="White" Font-Bold="True"
> Font-Names="Gill Sans MT">Work Order:</asp:label><asp:label id="lblCust"
> style="Z-INDEX: 117; LEFT: 114px; POSITION: absolute; TOP: 66px"
> runat="server" ForeColor="Yellow" Font-Bold="True" Font-Names="Gill Sans
> MT"></asp:label><asp:label id="lbl_Cust" style="Z-INDEX: 114; LEFT: 7px;
> POSITION: absolute; TOP: 66px" runat="server" Width="70px"
> ForeColor="White" Font-Bold="True" Font-Names="Gill Sans
> MT">Customer:</asp:label><asp:label id="lbl_User" style="Z-INDEX: 113;
> LEFT: 7px; POSITION: absolute; TOP: 34px" runat="server" Width="70px"
> ForeColor="Yellow" Font-Bold="True" Font-Names="Gill Sans
> MT">User:</asp:label><asp:label id="lblStation_label" style="Z-INDEX:
> 112; LEFT: 7px; POSITION: absolute; TOP: 15px" runat="server"
> Width="70px" ForeColor="Yellow" Font-Bold="True" Font-Names="Gill Sans
> MT">Station:</asp:label><asp:textbox id="txtFinish" style="Z-INDEX: 104;
> LEFT: 141px; POSITION: absolute; TOP: 214px" runat="server" Width="71px"
> Font-Size="XX-Small" BackColor="Silver"
> ReadOnly="True"></asp:textbox><asp:label id="lblScan" style="Z-INDEX:
> 109; LEFT: 54px; POSITION: absolute; TOP: 265px" runat="server"
> Width="169px" ForeColor="Yellow" Height="23px" Font-Bold="True"
> Font-Size="Small" Font-Names="Gill Sans MT">Scan Serial
> Number(s)</asp:label><asp:textbox id="txtScan" style="Z-INDEX: 108;
> LEFT: 63px; POSITION: absolute; TOP: 293px" runat="server" Width="144px"
> AutoPostBack="True"></asp:textbox><asp:label id="lblFinish"
> style="Z-INDEX: 107; LEFT: 159px; POSITION: absolute; TOP: 194px"
> runat="server" Width="47px" ForeColor="Cyan" Height="15px"
> Font-Bold="True" Font-Size="X-Small" Font-Names="Gill Sans
> MT">Finish</asp:label><asp:label id="lblStart" style="Z-INDEX: 106;
> LEFT: 82px; POSITION: absolute; TOP: 194px" runat="server" Width="47px"
> ForeColor="Cyan" Height="15px" Font-Bold="True" Font-Size="X-Small"
> Font-Names="Gill Sans MT">Start</asp:label><asp:textbox id="txtCount"
> style="Z-INDEX: 105; LEFT: 143px; POSITION: absolute; TOP: 339px"
> runat="server" Width="43px"
> BackColor="Silver"></asp:textbox><asp:textbox id="txtStart"
> style="Z-INDEX: 103; LEFT: 60px; POSITION: absolute; TOP: 214px"
> runat="server" Width="71px" Font-Size="XX-Small" BackColor="Silver"
> ReadOnly="True"></asp:textbox><asp:label id="lblStation" style="Z-INDEX:
> 101; LEFT: 114px; POSITION: absolute; TOP: 14px" runat="server"
> ForeColor="White" Font-Bold="True" Font-Names="Gill Sans
> MT"></asp:label><asp:label id="lblUser" style="Z-INDEX: 102; LEFT:
> 114px; POSITION: absolute; TOP: 35px" runat="server" ForeColor="White"
> Font-Bold="True" Font-Names="Gill Sans MT"></asp:label>
> <HR style="Z-INDEX: 110; LEFT: 6px; POSITION: absolute; TOP: 168px;
> HEIGHT: 5px" width="100%" color="#ff0000" SIZE="5">
> <asp:Button id="btnList" style="Z-INDEX: 124; LEFT: 73px; POSITION:
> absolute; TOP: 389px" runat="server" Width="127px" Height="30px"
> Text="Show List Scanned"></asp:Button></form>
> </body>
> </HTML>
>
>
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
S. Justin Gengo Guest



Reply With Quote

