473,513 Members | 2,560 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.Click event handler is not getting called after a Click ?

We're using .NET 2.0, VB. I expect a .Click event handler to be called, but it's not.

When I click on the webpage link named btnSearch, the confirmSearchOK() javascipt function is called(I see this when I uncomment the alert() ), which contains the __doPostBack() call. On the .VB side, the handler never gets called. BTW, the handler was created by double-clicking on the .ASPX object in the 'Design' mode.

Any help would be appreciated.
Thanks

Javascipt:
Expand|Select|Wrap|Line Numbers
  1. function confirmSearchOK() {
  2.         var planSel = document.getElementById("<%= ddlPlanID.ClientID %>").selectedIndex;
  3.         var opSel = document.getElementById("<%= ddlOfferingPeriod.ClientID %>").selectedIndex;
  4.         var useEASi = document.getElementById("<%= hUseEASi.ClientID %>").value;
  5.         var epError = 0        
  6.  
  7.         if( useEASi == 'Y'){
  8.             if (document.getElementById("<%= ddlEnrollmentPeriod.ClientID %>").selectedIndex == 0)
  9.                 epError = 1;        
  10. }
  11.  
  12. //alert("planSel: "+planSel+", opSel: "+opSel+", useEASi: "+useEASi+", epError: "+epError );
  13.  
  14.         if( planSel == 0 )
  15.             alert("Error, must choose a Plan prior to Search");
  16.         else if( opSel == 0 )
  17.             alert("Error, must choose an Offering Period prior to Search");
  18.         else if( epError == 1 )
  19.             alert("Error, must choose an Enrollment Period prior to Search");
  20.         else                
  21.             __doPostBack('btnSearch','');            
  22. }
  23.  
asp.net
Expand|Select|Wrap|Line Numbers
  1. <td align="left" class="FormFieldCell" colspan="3" style="white-space: nowrap">
  2.    <EASI:LinkButton ID="btnSearch" runat="server" CausesValidation="False" ClientScript="confirmSearchOK();"                  UseSecurityLevel="True">Search</EASI:LinkButton></td>

VB.NET event handler

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
  2.  
  3.   'handle the event here
  4.  
  5. End Sub
  6.  
Oct 12 '10 #1
1 1902
Frinavale
9,735 Recognized Expert Moderator Expert
What is an "EASI" LinkButton?
Why don't you just use an ASP.NET LinkButton?

Try modifying your JavaScript method so that it returns "true" if you want the postback to occur...and "false" if you want it to stop.

Then change the LinkButton to so that it "returns" the value that is returned by the JavaScript method... This should stop the postback from occurring (but then again I've nevers een an EASI LinkButton before.......)
Expand|Select|Wrap|Line Numbers
  1. <EASI:LinkButton ID="btnSearch" runat="server" CausesValidation="False" ClientScript="return confirmSearchOK();" UseSecurityLevel="True">Search</EASI:LinkButton>
JavaScript modification suggestion:
Expand|Select|Wrap|Line Numbers
  1. function confirmSearchOK() {
  2.         var planSel = document.getElementById("<%= ddlPlanID.ClientID %>").selectedIndex;
  3.         var opSel = document.getElementById("<%= ddlOfferingPeriod.ClientID %>").selectedIndex;
  4.         var useEASi = document.getElementById("<%= hUseEASi.ClientID %>").value;
  5.         var epError = 0        
  6.  
  7.         if( useEASi == 'Y'){
  8.             if (document.getElementById("<%= ddlEnrollmentPeriod.ClientID %>").selectedIndex == 0)
  9.                 epError = 1;        
  10. }
  11.  
  12. //alert("planSel: "+planSel+", opSel: "+opSel+", useEASi: "+useEASi+", epError: "+epError );
  13.  
  14.         if( planSel == 0 )
  15.         {    alert("Error, must choose a Plan prior to Search");
  16.              return false;
  17.         }
  18.         else if( opSel == 0 )
  19.         {    alert("Error, must choose an Offering Period prior to Search");
  20.               return false;
  21.         }
  22.         else if( epError == 1 )
  23.         {    alert("Error, must choose an Enrollment Period prior to Search");
  24.              return false;
  25.         }
  26. //        else                
  27. //            __doPostBack('btnSearch','');            
  28.         return true;
  29. }
-Frinny
Oct 14 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
13547
by: Assaf Weinberg | last post by:
Using ASP.NET web form with VB.NET I have a page with a calendar control that onSelectionChanged builds a table control showing the events scheduled for the selected calendar days. One of the columns in this table contains linkbuttons that, when clicked, should execute some code (currently an event handler called showEvent) that displays...
2
2771
by: Nikki | last post by:
Hi, I m developing a Windows application in which i want to create a context menu, having variable number of submenus depending on the the list in the file. I m able to create these submenus at runtime by reading the file. But the problem is that there is no fixed count of submenus and becaz of that i m not able to figure out "How to create...
2
2798
by: George | last post by:
I'm having a weird problem. When I double-click a Web server control that I have on my design-time Web form, such as a button, it puts the event handler in the Code Behind as a Private Sub routine. However, when I try to compile, I get an error saying that I can't access that event handler because it is Private. When I change the event...
1
2718
by: Divya | last post by:
Hello This is my 1st project where I have to create a Webcontrol. I have created a simple custom control with a button and 2 labels added to a panel. My problem is that the event handler that I have assigned to the button , is not getting invoked. Could anyone please go thru the code and let me know what I am missing here? Thanks in advance ...
2
1338
by: Shreyash B. Patel | last post by:
Hi, I have a WebControl.Table on my WebForm. In the Table I have LinkButtons. I inserted and created these link buttons dynamically. Please Look at the Code below. LinkButton lb = new LinkButton(); lb.Text = "Details"; lb.Click += new System.EventHandler(this.LinkButton_Click); Table1.Rows.Cells.Controls.A(lb);
3
2776
by: Randy Fraser | last post by:
What is the proper way of declaring an override on a button click event for a base form. I am getting " Cannot bind an event handler to the 'Click' event because it is read only." listed in the events. It works but should I be getting this message. Base form: Protected Overridable Sub btnSave_Click(ByVal sender As System.Object, ByVal
1
2036
by: Kuldeep | last post by:
Hello All, Visual Studio 2005 ASP.NET 2.0 C#.NET 2.0 I have an application which has a Button click event procedure as given below. protected void btn_Click(object sender, EventArgs e)
0
2188
by: weird0 | last post by:
i have successfully emebedded visio drawing tool in my application. Infinite number of shapes can be added to the drawing. How can i write double click event handler for the the shapes added to my diagram? Other than that, how can i loop through all the shapes in the diagram, to get their information? Visio Guy Amir Diwan
0
1204
by: Navid | last post by:
Hello, I have a tree view which has Check Box's beside each node. In the BeforeCheck event Handler I have canceled the event to prevent the user from Checking/ Un-checking the box. I am trying to now set up the DoubleClick event but the first time the user double clicks the event is not called. For example the first time clicked it will...
4
3712
by: SAL | last post by:
Hello, I'm working, basically my first, AJAX page and am having a few problems. One is that the Click event for a button I have in UpdatePanel1 is not getting called. I've tried with the button both inside and outside of the updatepanel and the event doesn't get called either way. What might I be missing here? Incidently, something else,...
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5103
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4759
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3255
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.