enter-key works with two inputboxes but not with olny one.

Hi,

There is a form with two inputboxes and a submit button.The focus is on the 
first inputbox.
When the user presses the enter-key without having entered some text, the 
javascript message "wrong text" appears. This works.

But if i remove the second inputbox, leaving only the first inputbox and the 
submit button, pressing the enter-key without any text does not show the 
javascript message. Nothing happens. The focus remains in the inputbox. You 
can see the page is postbacked, but that's all.

Why does it work with two inputboxes and not with one? And how to fix it?
Thanks
Phil


<body><form id="form1" runat="server">
<table>
 <tr><td><input id="Text1" type="text" runat="server" /></td></tr>
 <tr><td><input id="Text2" type="text"  runat="server" /></td></tr>
<tr><td><input id="Submit1" type="submit" runat="server" 
/></td></tr></table>
</form></body>

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As 
System.EventArgs) Handles Me.Load
 Text1.Focus()
 End Sub

Protected Sub Submit1_ServerClick(ByVal sender As Object, ByVal e As 
System.EventArgs) Handles Submit1.ServerClick
        Dim beh As String
        beh = Text1.value
        If beh = "xxx" Then
             Response.Redirect("start.aspx", False)
        Else
            Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), 
"myscript", _
            " alert('wrong text');", True)
        End If
End Sub 


0
Phil
8/28/2010 10:22:23 AM
dotnet.framework.aspnet 1425 articles. 0 followers. Follow

2 Replies
750 Views

Similar Articles

[PageSpeed] 36

i found it: put another inputbox with property invisible.
"Phil" <pf@ss.nl> schreef in bericht 
news:egY7prpRLHA.5732@TK2MSFTNGP02.phx.gbl...
> Hi,
>
> There is a form with two inputboxes and a submit button.The focus is on 
> the first inputbox.
> When the user presses the enter-key without having entered some text, the 
> javascript message "wrong text" appears. This works.
>
> But if i remove the second inputbox, leaving only the first inputbox and 
> the submit button, pressing the enter-key without any text does not show 
> the javascript message. Nothing happens. The focus remains in the 
> inputbox. You can see the page is postbacked, but that's all.
>
> Why does it work with two inputboxes and not with one? And how to fix it?
> Thanks
> Phil
>
>
> <body><form id="form1" runat="server">
> <table>
> <tr><td><input id="Text1" type="text" runat="server" /></td></tr>
> <tr><td><input id="Text2" type="text"  runat="server" /></td></tr>
> <tr><td><input id="Submit1" type="submit" runat="server" 
> /></td></tr></table>
> </form></body>
>
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As 
> System.EventArgs) Handles Me.Load
> Text1.Focus()
> End Sub
>
> Protected Sub Submit1_ServerClick(ByVal sender As Object, ByVal e As 
> System.EventArgs) Handles Submit1.ServerClick
>        Dim beh As String
>        beh = Text1.value
>        If beh = "xxx" Then
>             Response.Redirect("start.aspx", False)
>        Else
>            Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), 
> "myscript", _
>            " alert('wrong text');", True)
>        End If
> End Sub
> 


0
Luc
8/29/2010 1:51:40 PM
On Aug 28, 12:22=A0pm, "Phil" <p...@ss.nl> wrote:
> Hi,
>
> There is a form with two inputboxes and a submit button.The focus is on t=
he
> first inputbox.
> When the user presses the enter-key without having entered some text, the
> javascript message "wrong text" appears. This works.
>
> But if i remove the second inputbox, leaving only the first inputbox and =
the
> submit button, pressing the enter-key without any text does not show the
> javascript message. Nothing happens. The focus remains in the inputbox. Y=
ou
> can see the page is postbacked, but that's all.
>
> Why does it work with two inputboxes and not with one? And how to fix it?
> Thanks
> Phil
>
> <body><form id=3D"form1" runat=3D"server">
> <table>
> =A0<tr><td><input id=3D"Text1" type=3D"text" runat=3D"server" /></td></tr=
>
> =A0<tr><td><input id=3D"Text2" type=3D"text" =A0runat=3D"server" /></td><=
/tr>
> <tr><td><input id=3D"Submit1" type=3D"submit" runat=3D"server"
> /></td></tr></table>
> </form></body>
>
> =A0Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
> =A0Text1.Focus()
> =A0End Sub
>
> Protected Sub Submit1_ServerClick(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Submit1.ServerClick
> =A0 =A0 =A0 =A0 Dim beh As String
> =A0 =A0 =A0 =A0 beh =3D Text1.value
> =A0 =A0 =A0 =A0 If beh =3D "xxx" Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0Response.Redirect("start.aspx", False)
> =A0 =A0 =A0 =A0 Else
> =A0 =A0 =A0 =A0 =A0 =A0 Page.ClientScript.RegisterClientScriptBlock(Me.Ge=
tType(),
> "myscript", _
> =A0 =A0 =A0 =A0 =A0 =A0 " alert('wrong text');", True)
> =A0 =A0 =A0 =A0 End If
> End Sub

I think that you culd get better results using aspnet's validation
controls. You'll get validation on client side, among other benefits.
http://msdn.microsoft.com/en-us/library/aa479013.aspx
Best regards,
0
Cubaman
8/30/2010 8:05:50 AM
Reply:

Similar Artilces:

What do you do if you have auto save set, but it is not working?
I have auto save in Excel set to every 5 minutes, but it is not auto saving the data. What should I do to fix it? Jennifer What version of Excel? XP (2002) & 2003 _do not_ have an AutoSave feature. If you are referring to AutoRecover (Tools>Options--Save), that is something totally different. It doesn't save your working file, but stores the data separately in a temporary file for recovery purposes in the event that XL or the system crashes while the file is open. HTH |:>) "Jennifer" wrote: > I have auto save in...

How do I get a graphy with 2 data sets to have 2 Y axis one for each data set?
How do I get a graphy with 2 data sets to have 2 Y axis one for each data set? On Jul 20, 5:26 am, libertyforall <r...@royhuff.com> wrote: > How do I get a graphy with 2 data sets to have 2 Y axis one for each > data set? Hi libertyforall, have a look at Jon Peltier's beatiful site, especially: http://peltiertech.com/Excel/Charts/ColumnsOnTwoAxes.html Have fun, cheers Michael ...

For Some Reason My Schedule is Working through Weekends
Is there anyway to correct this in one operation?? -- TMI Contractors ------------------------------------------------------------------------ TMI Contractors's Profile: http://forums.techarena.in/members/216904.htm View this thread: http://forums.techarena.in/microsoft-project/1338262.htm http://forums.techarena.in Check the calendar for the project, and if a different calendar has been assigned to specific tasks (Tools > Change Working Time, Project > Project Information, and the Task Calendar column respectively). Check the resources assigned to the tasks...

indicating alternate keys in Visio 2002
In my ERD diagram, I can indicate primary keys, foreign keys, and indexes. How in the world do I indicate an alternate key? I want it to show the AK# in the left column similiar to the PK and FK that are displayed. I have tried numerous things and cannot find the way to indicate that an attribute is an alternate key. The help index says that the AK will be shown, but I can't find any information on how to identify the attribute as being an alternate key. HELP!!! 1.Double-click the Entity shape 2. Click on Primary ID 3. Select the "Generate as" drop down menu It should show ...

Can I designate one our computers to be the Outlook server?
I'm new to using Outlook at home and definitlely a novice a terminology but here goes ..... We use Outlook 2003. We have two computers - a PC and a notebook. I would like to set up the notebook as our Outlook "server" (have all e=mail traffic come through it and be disributed to the PC into "mailboxes or "accounts" or files, whatever the term for all family members. Can this be done and how? Outlook is a client, not a server, so, no, you cannot set up Outlook to receive mail then deliver to various mailboxes. You would need server software to do this. H...

Suddenly -- Two PERSONAL FOLDERS???
Hi, All of a sudden, I have 2 Personal Folders!!!! They seem identical, and I cannot get rid of one or the other. * The only thing recently changed is the installation of XP SP-2. * All previous XP-Pro updates have been installed * Running Outlook 2000, and all updates are installed (never had any problems with these...they were installed "long ago." Thank you for your help! "Howie" ...

combining data from separate sheets into one
Greetings I would be grateful if someone could start me off on a macro to combine data (size variable) from a number of sheets (number unknown) from a single file. The data will always start in the same cell, A6. Many thanks Yours Andrew j Fife Can you be a bit more specific on what exactly do you want to do? Do you want to, say, add the values of cell A6 in all sheets in A6 in a totals sheet, or something like this? Do you want to do this for a range of cells? Does your totals sheet have a specific name (so it can be excluded from the summation? Nikos Y. >-----Original Message...

Formulas dont work
I am trying to do a vlookup function with data that is imported and calculated from another cell, and it shows a result of #na. c3 is formated to custom "m" to show the number of the month from cell b3. b3 is "October-04" c3 shows "10" d3 "job name" b100 "10" a100 =vlookup(b100,c3:f20,2,false) result is "#na" If I enter "10" into cell c3 with format set to general, then the result shows the correct answer. Is there a way to correct this? -- comotoman -----------------------------------------------------------------...

Autofilter for more than one condition!!
Hi Is it possible to have an autofilter on the header bar that can filter for more than condition e.g I have 600 rows of data, In Col A there are various groups names ; Alpha, Beta, Charlie,Delta etc. I would like a filter to show me all the entries for Alpha, Beta and Delta at the same time. So want to filter col A for not just one but say 3 or 4 conditions... is this possible and can it be written in code? Please help as cant seem to find a way to do this!! Thnx One way Sub Macro1() Dim rng As Range Columns("F:F").Insert Set rng = Range("E1", Range("E1...

MFC Application working in background.
Hi, I am fairly newbie to MFC, i would like to know if there is any way that my MFC Application works in background, no any form. I placed that code in InitInstance () but program crashes. I have an endless while loop for background working, Why i cant place that loop in InitInstance(). Any Idea? Thanks in advance Fahad Ashfaque fahad_ashfaque@yahoo.com Do you mean you want a GUI-less application that runs in the background - if so you should take a look at Windows Services. On the other hand if you mean you want to have an MFC app with a GUI 9that does a background task) then you ...

Auto enter date?
Hi! me again! is there any way i can get excel to auto enter dates that jump by 7 days every 7th cell along? cheers steve Ive worked part of this out. in cell G1 =DATE(105,1,3) in cell M1 =G1+(WEEKDAY(G1)>=1)*7-WEEKDAY(G1)+1 but its displaying the time...i just want the date.... steve "R.P.McMurphy" <rpmcmurphy@ntlworld.com> wrote in message news:43118dff$0$17506$ed2e19e4@ptn-nntp-reader04.plus.net... > Hi! me again! > > is there any way i can get excel to auto enter dates that jump by 7 days > every 7th cell along? > > cheers > > s...

If Statement with Two Conditions
I'm trying to do an if statement with two conditions like the following If a value falls between two dates then give it a value of 1, if not give it a value of 0. The if statement works well with one condition but when I try to do something like this = if (a2<=b2<=c2,1,0) it does not work. Help Leroy Leroy, Try something like =IF(AND(A2<=B2,B2<=C2),1,0) -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Leroy" <anonymous@discussions.microsoft.com> wrote in message news:EF57802D-CA6F-4A45-95FB-9807FFEA1...

Merge customers from two different stores
I have had plenty (OK, too much) experience with merging accounts at the Store Ops level. The KB article on this topic includes the necessary queries and it seems to work just fine. Today I came across my first duplicate customer where the second account was created at another store. Is there a way to merge the purchase history & A/R for two accounts from separate databases? Tom -- The worst words in business: "We''ve always done it that way" -- Stop Fishing for eMail. This is a multi-part message in MIME format. ------=_NextPart_000_0035_01C6A72E.DEA7A220 Cont...

Combined bar and line chart (two Y axis) how to make excel know which data goes where
Hello all, after the super fast problem fixing last time i had a problem, i'd like to ask the excel collective for some more help... :) now trying to plot a combined bar chart and line graph. I basically want all the sets of data except one to appear as columns plotted against the axis on the left and the last set of data (which is a cumulative value of the data appearing for the columns) plotted against the right hand axis as a line. I can plot the graph fine, but out of the 7 sets of data which i want to appear as 6 sets of columns and one line, i get four sets of columns and three ...

Can a non-admin force the check in of one of their projects on Pro
Not sure whether this is a stupid question, but we are using impersonation to check out a project to a certain user. As the project is checked out in a different session, when the user is ready to work on the project they will need to force check in and then re-check out the project. Is this possible for a non-admin to do? And if so, how would we do this? We're using Project Server 2007 On Mar 9, 9:18=A0am, Hutchingsj <Hutchin...@discussions.microsoft.com> wrote: > Not sure whether this is a stupid question, but we are using impersonatio= n to > check out a pro...

GP 7.5 Key Recovery
Does anyone know a way of extracting a product key from an existing GP installation? We are upgrading hardware to a new server and have lost our hard copy of this key. ...

Restore button does not work
Thanks in advance for any assistance. I searched through the forum for this problem and found a couple of threads related to it, but none had a definitive answer. I have been having a problem in the last week or so, wherein the Restore button in the upper right corner of the Excel dialog (not the inner worksheet dialog) does not work correctly. If Excel is maximized, clicking on Restore will minimize the dialog onto the toolbar, leaving it only visible as a depressed button on the toolbar. Clicking on this button does nothing. Right clicking on the button shows a dialog containing the fol...

Search isn't working in the newsgroup
I tried to search for install, reinstall, setup, etc. I get the following: ------------------------------------------------------------------- Your query for "install" did not return results. The following may help you find the results you were looking for: Check your spelling. Enter a term or phrase that's less specific. Try different phrasing. Try fewer words. ---------------------------------------------------------------------- What is the problem? -- David Wertz Got me. Try an Advanced Search of newsgroup microsoft.public.money at http://groups.google.com. "D...

i need to create a chart from data from one workbook in another wo
hi new to excell so please be kind. i need to create a series of charts from different sets of data in one workbook, and have the charts show in another seperate workbook, and update automaticly when the data changes in the first workbook. i know how to create charts, its just that i can't get it linking from one workbook to another please help Mark Hi, An easy approach would be: Make the charts in the workbook containing the data. Cut and paste those charts into a new workbook. The charts are still linked to the original workbook. If you make changes in the data, the charts...

windows 7 search not working
Hi, I have a brand new laptop running Windows 7 Home Premium x64. Windows Search does not work - there is no drive activity and I get no results. I've seen the KB article 977380 about Win7 search not working and I have tried the hotfix, but with no luck. Search still does not work. The indexing service is running, AFAICT, and the drive properties are set to allow indexing. Anyone know the answer to this? (please don't say Google Search 8-) George On Thu, 19 Aug 2010 03:33:47 -0400, George Neuner <gneuner2@comcast.net> wrote: I was advised by email to tr...

MS SQL Insert Data from One table to another
Hi guys, After seeing the benefits one can derived in developing applications running on sql, I have tried my hands on some small application, but with some challenges, and I will be grateful if someone can help me out. I want the contents one table to be added to some specific fields in another table. for eg. Table 1 P_Id pMonth pYear pRegistrar pFormType pCasetype ..... table 2 fID FormName 1 Land 2 Commercial 3 Defamation .... ..... I want to insert the values of table 2 to table 1 spec...

Sending mail out via two routes
Hi, I wonder if anyone here can help me here... We have an Exchange 5.5 server (Will be upgrading this to 2003 at some point!) Currently, all mail in and out of the company goes via another (In-House) server with GFI Mail Essentials installed. We have two ADSL providers, and a firewall that routes all mail traffic over one provider (It routes everything else over the other provider, unless that line is down, then it routs everything over the working connection) - we would like to configure it so, if this "mail" ADSL line goes down, the other line will then take over sending ...

Two separate Exchange environments
Are there any third party tools that allow any kind of calendar info sharing between two autonomous Exchange environments in two completely separate AD environments? Users in company A would like to be able to see the free/busy data of users in company B. E2K3 used by both companies, and a mix of Outlook versions from 2000 to the latest used as clients. Thanks! Look at the Inter-Org Replication Tool http://www.microsoft.com/downloads/details.aspx?familyid=e7a951d7-1559-4f8f-b400-488b0c52430e&displaylang=en -- Bharat Suneja MVP - Exchange www.zenprise.com NEW blog location: e...

why does Random: Rnd() not work for random sort?
Hi I'm trying to generate some random numbers in a query in order to allow a random sort of the query using a calculated field called Random: Rnd(). Problem is, the exact same random number is generated for every record in the query thus negating any ability to create a random sort. I've also tried Random: Rnd(-1) Random: Rnd(0) and Random: Rnd(1) as well as other integers with the same result. I'm using Access 2007. Any help/thoughts? thanks, craig On Tue, 27 Nov 2007 22:35:19 -0600, "Craig" <msaccess@howardhowardfine.com> wrote: >Hi >...

How Does One Limit Outlook Help To Outlook?
If I need to look something up related to Printer I don't want the help program to tell me how to "Find and install printer drivers for Windows Vista" followed by "Find printer drivers for Windows XP". I entered Printer into Outlook help and the first ten results were: Add or remove a printer Change your default printer Find and install printer drivers for Windows Vista Find a printer manufacturer's Web site Find printer drivers for Windows XP Get the version number for your Office program and information about your computer Change an ink or ton...