asp.net2.0
-
whenever i press enter key the form gets refresh ie postback occurs. How can this be avoided.
Just in case you missed the posting above titled "How to get an answer to your question". Make note of item number 3. For those new to message boards please try to follow a few simple rules when posting your question. Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears. Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with. Keep the subject line brief, but descriptive. eg "File Serialization problem" Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can. If you are posting source code with your question, place it inside <pre></pre> tags, or click the "Ignore HTML tags in this message" check box. Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job. Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted. Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice. If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums. No advertising or soliciting. We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal. cheers, Chris Maunder CodeProject.com : C++ MVP To answer the question, use AJAX
only two letters away from being an asset
-
whenever i press enter key the form gets refresh ie postback occurs. How can this be avoided.
There are many ways. One simple way is to add client-side script to handle "onsubmit" and cancel the event. This does not affect programmitcal form submission (ie. calls to form.submit) so asp.net controls still post back as normal, but simply having an INPUT inside the form will not lead to postback when pressing enter. In the "head" section, include the following script:
attachEvent("onsubmit", function
{
event.cancelBubble = true; event.returnValue = false;
});