I have a form which has a table and cells which I have programmed to edit but when I hit the submit key the form gets submitted

I only want the cell to accept the enter key and the form should not get submitted at all as I am using ajax to update the cell contents
goodkAsked:
Who is Participating?
 
Brian TaoSenior Business Solutions ConsultantCommented:
Ah.... it's asp.  Remove the  runat="server" part from your form tag and see if it works.

And if you're trying something interactive that only happens on the client side, remove those  runat="server" from the input tags too.
0
 
Mark BullockQA Engineer IIICommented:
The form submit button should call your javascript function when it's clicked. Like this:
<input type="submit" name="Submit" value="Submit" onclick="myJavaScriptFunction()"/>
0
 
goodkAuthor Commented:
So I have to differentiate where the cursor is when enter is clicked?
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
goodkAuthor Commented:
Is there a comprehensive example how to handle this?
0
 
Brian TaoSenior Business Solutions ConsultantCommented:
Add onsubmit="return false" in your form tag then you're good.
0
 
goodkAuthor Commented:
http://right-match.com/testit.aspx

I am doing something dumb; can't figure it out.  Please see if you can help

See all I need help when I hit the enter key when editing to not submit the form but just the table cell
0
 
Dave BaldwinFixer of ProblemsCommented:
The standard operation of forms for the past 20 years has been that if you press enter while you are in any of the fields in the form, the form will be submitted.  That is normal.  You have to include some javascript if you want to suppress that operation.  Brian's onsubmit="return false" will do it in a simple way that covers that whole form.
0
 
goodkAuthor Commented:
I thought I had that
0
 
Dave BaldwinFixer of ProblemsCommented:
You haven't shown us any of your code so we can see what you're doing.
0
 
goodkAuthor Commented:
<body>
    <form id="form1" onsubmit="return false" runat="server">
    Edit:
    <input id="EditCheckbox" runat="server" onclick="form1.submit()" type="checkbox"  value="Edit" />
    <div class="verticalScroll">
        <%
            HttpContext.Current.Session["Application"] = "rightmatch";


            Response.Write(xrun());%>
    </div>
    </form>
</body>
0
 
goodkAuthor Commented:
can you do source on the link I have?  I basically have ajax called when the table cell is hit.  My problem is that the form keeps getting submitted after I hit the cell and put text and hit the Enter key
0
 
Dave BaldwinFixer of ProblemsCommented:
I think you'll find that onclick="form1.submit()" bypasses onsubmit="return false".

Of course, why are you hitting the Enter key?  Like I said above, for the last 20 years, forms have always been submitted when you press Enter in one of the form fields.
0
 
Dave BaldwinFixer of ProblemsCommented:
I just looked at the source for your page.  Since you are using 'Viewstate', I'm not sure you can change any of that behavior.
0
 
goodkAuthor Commented:
Well, all the javascript is visible and I do not understand what could trigger the form into submit

When text field is on for edit why it would not only submit that cell?  What else is there on the form which is making it submit??
0
 
goodkAuthor Commented:
http://right-match.com/test/autocomplete.aspx

I tried the above and it works.  Did not change the viewstate.

So may be something is wrong with my original form.  Let me work on it and narrow the problem down before i revert to you experts
0
 
Dave BaldwinFixer of ProblemsCommented:
You might want to click on "Request Attention" and get some others to look at your question.  I think that using Viewstate complicates the problem.
0
 
goodkAuthor Commented:
I did remove the runat="server" and it did not help.

asp.net is so frustrating.

Hate it. Wish I could turn off all the functionality of asp.net and just use c# and javascript to do my work.
0
 
goodkAuthor Commented:
This problem is not resolved but the expert did answer the question
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.