Pressing Enter key should trigger JavaScript validation of one particular button's click event before form submit in ASP.NET using VB.NET? - Abhilash Matlapudi

Hi friends,

I'm a entry level s/w engineer working in a leading financial s/w company based in India.

Coming to the point,

I'm working on ASP.NET using VB.NET in VS.NET 2003(.NET framework 1.1)

I have a aspx search screen with few fields to accept input for search criteria. This page contains 2 aspx image buttons, namely a 'Search' button and other image button 'Setup' is used for page redirection(using response.redirect("") or server.transfer("") options. On clicking the Search button, it displays any matching search criteria in a DataGrid with-in a panel which in turn have 3 aspx image buttons for each row. These 3 buttons withing the grid opens a page in 3 different, Edit, View(Readonly), Delete modes.

The problem now is that on pressing Enter key, the application should fire Search button along with javascript validations(atleast one field should be filled inorder to proceed with search) written for that search button's click event. For this I use

<from id="form1" onsubmit="return Validate();">

in design mode of aspx page so that javascript is called on form submit.(I want all client side validations to be called before form submission) 

And in codebehind I use

Page.RegisterHiddenField("__EVENTTARGET", "IbtnSearch")

to focus on that search button on pressing Enter key.

Everything seems working fine, BUT If I click the other redirection button 'Setup' it calls the validate() javascript function and asks me to enter atleast one search criteria even for redirection.

To solve this,
1.>I removed the onsubmit option in form tag but I need to do all the basic validation in server side as pressing enter key doesn't fire client side validation for that button.
2.>Alternatively, I tried to use html image for 'Setup' button by retaining the onsubmit option to redirect from this search page to Setup page. Everything seems working fine, BUT if I click the aspx image button within the Datagrid after making a valid search criteria, it again calls the validate() javascript function as I've retained onsbumit option in form tag in design mode.

I heard that in .NET framework 2, we can solve this problem? If yes plz tell me how to do it. Also kindly give me a solution if I wanted to use in the existing .NET framework 1.1. I should make it work in existing framework 1.1

Please do needful.

Thanks in Advance,
Abhilash Matlapudi

0
Matlapudi
9/26/2005 7:43:36 AM
asp.net.client-side 24353 articles. 2 followers. Follow

2 Replies
2611 Views

Similar Articles

[PageSpeed] 6
Get it on Google Play
Get it on Apple App Store

I would look at using the RequiredFieldValidator (and/or other ASP.net Validators).  Then you can set the setup button so that CausesValidation=false.
HTH, rchern.

Churned Ajax Toolkit

Please choose "Mark as Answer" for the posts that lead you to a solution.
0
rchern13
9/26/2005 3:05:58 PM
Here are a few thoughts:
1. Use the Microsoft validators or a third party validation system. You don't need to write your own.
2. Take a look at this article for a lot of info: www.aspalliance.com/699. It will tell you how to make a submit button NOT validate (set CausesValidation=false) and how to make separate buttons fire different validators ("validation groups").
3. When there is only one textbox on the page, IE has a strange behavior when Enter is hit from within the textbox. It skips calling <form onsubmit=>! There are two common work arounds. 1) add another TextBox. If not needed, just hide it by using style="display:none". 2) attached some javascript for the onkeypress event to the <form> or <body> tag that capture the Enter click and fire the form.submit() event. You can search these forums for "onkeypress" to find examples.
--- Peter Blum
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
www.PeterBlum.com
0
PLBlum
9/26/2005 3:10:32 PM
Reply:

Similar Artilces:

How do I invoke the button's click event using using VB.Net
I am programming VB.Net for my ASP.net project. Can anyone tell me how do I code the "button" server control to invoke the click event? I believe one line of VB code would do. It didn't work when I try btnButton.Click() ???? Thank You! You can always call btnButton_Click(Me, EventArgs.Empty) If I remember correctly. This assumes you have a btnButton_Click(sender as Object, e as EventArgs) sub somewhere in your page. Greg You can also do btnButton_Click.PerformClick() !Jarod Sorry... Forget... The PerformClick method exist only for windows forms b...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

validate Client-Side, Two Vaidation Groups by ONE Button's Click Event
Hi, I am having a form which contains TWO TextBoxes, TWO RequiredFieldValidators, TWO Validation SummaryControls  which are assigned to ValidationGroup named  'group1' and 'group2' respectively. Form also contains ONE Button control, on Button's Click event (Client-Side),                               I want to Validate Both Validation Groups. Please tell me, How could it be Possible ?  My Code is as follo...

tell m what i have to do,to traverse through records one after another-when i press next button on a form(using sql server,vb.net)
where "next_record" is declared has global variable.its displayin "first record" on the form.can anyone tell m what i have to do traverse through records one after another-when i press next button..plz reply m its very urgent...      Private Sub nxt_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nxt_btn.Click nextbtn() End Sub Public Function nextbtn() As StringDim str As String = "select * from table1" 'try to write "select distinct * from table1"Dim con As String = ConfigurationSetting...

superreview requested: [Bug 261108] using <enter> to submit a form triggers Warning ``reference to undefined property event.button'' [xs] in file ``chrome://communicator/content/contentAreaClick.js'',
neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> has asked Johnny Stenback <jst@mozilla.jstenback.com> for superreview: Bug 261108: using <enter> to submit a form triggers Warning ``reference to undefined property event.button'' [xs] in file ``chrome://communicator/content/contentAreaClick.js'', line 189, character 0. https://bugzilla.mozilla.org/show_bug.cgi?id=261108 Attachment 159834: Proposed patch https://bugzilla.mozilla.org/attachment.cgi?id=159834&action=edit ------- Additional Comments from neil@parkwaycc.co.uk <neil.parkw...

superreview granted: [Bug 261108] using <enter> to submit a form triggers Warning ``reference to undefined property event.button'' [xs] in file ``chrome://communicator/content/contentAreaClick.js'', l
Johnny Stenback <jst@mozilla.jstenback.com> has granted neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com>'s request for superreview: Bug 261108: using <enter> to submit a form triggers Warning ``reference to undefined property event.button'' [xs] in file ``chrome://communicator/content/contentAreaClick.js'', line 189, character 0. https://bugzilla.mozilla.org/show_bug.cgi?id=261108 Attachment 159834: Proposed patch https://bugzilla.mozilla.org/attachment.cgi?id=159834&action=edit ------- Additional Comments from Johnny Stenback <...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

Submit button (vb.net) code for form validation
Hi,I am going thru a lesson to learn how to validate information on a web form.In the lesson, we are told to use the HTML FileField controls.  Below is the code: Private Sub validateCategory_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles validateCategory.ServerValidate If optCategory.SelectedIndex = -1 Then args.IsValid = False Else args.IsValid = True End If End Sub Private Sub ValidateDoc_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles ...

Catch events in javascript from .NET usercontrol works in VB.Net
I've created a vb.net Windows Forms control that I've got working hosted in IE using the implementation found here: http://support.microsoft.com/default.aspx?scid=kb;en-us;305624 and here http://msdn.microsoft.com/library/default.asp?url=/msdnmag/issues/02/01/UserCtrl/TOC.asp I can access my properties and methods from javascript with no problem.  I tried to raise events in my UserControl and catch them in the HTML with javascript but I couldn't get it to work. The second article above on msdn explains how to source events from C#, but I need to get it working in VB.Net. A...

In datawindow.net,access the database from client side event using javascript
In powerbuilder,for example,a datawindow has two columns:itemno,description. input an itemno,validate it.if not found from the database,return 1 to trigger itemerror event; if found,get the description of the item from the database,and fill it into the column "description". The question is how to fulfill the function in web datawindow,through web service? if so,I need an example to realize it. You will need to use AJAX or make a round trip on item change event. -- Dean Jones CEO PowerObjects http://www.powerobjects.com (612) 339-3355 Ext. 112 TeamSybase * *...

Upgrading vb.net 2003 to vb.net 2008 the name '__o' is not declared
Hi I had an application in vb.net 2003. I chose to upgrade it to vb.net 2008. Now I have 153 errors telling me that the name '__o' is not declared. In one page where I get this error, It's on a <tr> statement. I searched in google and I saw that we could put <%=""%> at the beginning of the page, but I still have the error message. Any idea? Hi myriam_giroux,I think you need to be more specific information. When you are receiving errors during compilation in Visual Studio or Visual Web Developer, the Error list window will indicate the line in the sour...

use of vb.net and c#.net
i make a small website using vb.net,  in it i make a 2 class in C#.net. that i want to use in that website, i dont know how to call that class. let your class is  - class clsMyClass    {        public void myFunction()        {            // do something        }    } now the first way - create objectclsMyClass myObj = new clsMyClass();myObj.myFunction(); // call function================...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

.net validators + client-side javascript validation, EnableEventValidation=false
Scenario: 1. I have a DropDownList, with 2 listitems in the .aspx. appenddatabound=true and it is tied to a datasource (via datasourceid), autopostback=false, onchange=checkIfAddNew(this) [this is the client side onchange event]The second option on this dropdown is "Add New", and the checkIfAddNew function pops up a new window and when it returns, it adds the newly created option to the dropdown. In order for this to happen without asp.net getting mad, EnableEventValidation has to be set to false in the Page directive. In addition to this dropdownlist, there is a RequiredFieldValidator...

tell m how to traverse through records -when i press next button in the form(using sql-server&vb.net)
here,i have written code for displayin records from database on the form usin next button.but,when i click next button -it displays only first record.im not able to traverse through records...                   can anyone tell m,what is the error in the code& i have declared next_record has global variable... Private Sub nxt_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nxt_btn.Click nextbtn() End Sub Public Function nextbtn() As StringDim str As Stri...

Web resources about - Pressing Enter key should trigger JavaScript validation of one particular button's click event before form submit in ASP.NET using VB.NET? - Abhilash Matlapudi - asp.net.client-side

Resources last updated: 12/11/2015 4:01:15 AM