I have a odd thing happening. I have a sub that is called upon a button
click and it seems to be firing TWICE. I have no idea how this is happening
but I suspect is has something to do with page_load and IsPostBack.
The page has a form that displays a record. The user can delete the record
by clicking a delete button or update it by clicking an update button. The
delete sub calls a couple of other subs and functions and then displays a
confirmation message or an error. In my case...it's doing BOTH. I had
another classic VB developer look over it with me and we're both stumped.
I would love to post a URL but this still in early development and not live.
We even put temp counters in place and wrote them to the page and the delete
sub is indeed running twice. It deletes the record just fine and then runs
again and displays the error message since the MS SQL didn't delete the
record successfully (a second time).
Surely, I must be missing something obvious. Help is much appreciated!! The
person who figures this out gets a lifetime membership card to Hooters. =)
Protected Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
If Page.IsPostBack = False Then
'Load form with data
End If
End Sub
Protected Sub btnDelete_Click (ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnDelete.Click
Dim strDeleteRespon se As String
strDeleteRespon se = DeleteItem(intI temID)
If strDeleteRespon se = "OK" Then
'display confirmation message & clear fields
Else
'display error message from function
End If
End Sub
Protected Function DeleteItem(ByVa l intItemID As Integer) As String
'function calls a MS SQL stored procedure and returns "OK" or the
actual MS SQL error message
End Function 4 4286
ShaneFowlkes wrote: I have a odd thing happening. I have a sub that is called upon a button click and it seems to be firing TWICE. I have no idea how this is happening but I suspect is has something to do with page_load and IsPostBack.
The page has a form that displays a record. The user can delete the record by clicking a delete button or update it by clicking an update button. The delete sub calls a couple of other subs and functions and then displays a confirmation message or an error. In my case...it's doing BOTH. I had another classic VB developer look over it with me and we're both stumped.
I would love to post a URL but this still in early development and not live. We even put temp counters in place and wrote them to the page and the delete sub is indeed running twice. It deletes the record just fine and then runs again and displays the error message since the MS SQL didn't delete the record successfully (a second time).
Surely, I must be missing something obvious. Help is much appreciated!! The person who figures this out gets a lifetime membership card to Hooters. =)
I've had this sort of behaviour in the past when I'm using VBs Handles
clause (as you are using), but also stupidly called AddHandler with the
same event and function. Do you use AddHandler? Or do you have
AutoEventWireup set to true or absent in your aspx page? (Not sure
about this last - having never used it)
Damien
I'll be d@mned. I removed "Handles btnDelete.Click " from the sub and it
worked fine.
Is this a .NET2 bug? The "Handles" came from VS/VWD itself. I just dbl
clicked the asp:button to start building the sub. I never added it before
when coding by hand.
What cause this behavior? Why would it fire twice?
PS - THANK YOU.
"Damien" <Da************ *******@hotmail .com> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. . ShaneFowlkes wrote: I have a odd thing happening. I have a sub that is called upon a button click and it seems to be firing TWICE. I have no idea how this is happening but I suspect is has something to do with page_load and IsPostBack.
The page has a form that displays a record. The user can delete the record by clicking a delete button or update it by clicking an update button. The delete sub calls a couple of other subs and functions and then displays a confirmation message or an error. In my case...it's doing BOTH. I had another classic VB developer look over it with me and we're both stumped.
I would love to post a URL but this still in early development and not live. We even put temp counters in place and wrote them to the page and the delete sub is indeed running twice. It deletes the record just fine and then runs again and displays the error message since the MS SQL didn't delete the record successfully (a second time).
Surely, I must be missing something obvious. Help is much appreciated!! The person who figures this out gets a lifetime membership card to Hooters. =) I've had this sort of behaviour in the past when I'm using VBs Handles clause (as you are using), but also stupidly called AddHandler with the same event and function. Do you use AddHandler? Or do you have AutoEventWireup set to true or absent in your aspx page? (Not sure about this last - having never used it)
Damien
BTW - "Do you use AddHandler? Or do you have AutoEventWireup set to true or
absent in your aspx page? (Not sure about this last - having never used it)"
No to both.
"ShaneFowlk es" <sh********** @h-o-t-m-a-i-l.com> wrote in message
news:e7******** ******@TK2MSFTN GP02.phx.gbl... I'll be d@mned. I removed "Handles btnDelete.Click " from the sub and it worked fine.
Is this a .NET2 bug? The "Handles" came from VS/VWD itself. I just dbl clicked the asp:button to start building the sub. I never added it before when coding by hand.
What cause this behavior? Why would it fire twice?
PS - THANK YOU.
"Damien" <Da************ *******@hotmail .com> wrote in message news:11******** **************@ z34g2000cwc.goo glegroups.com.. . ShaneFowlkes wrote: I have a odd thing happening. I have a sub that is called upon a button click and it seems to be firing TWICE. I have no idea how this is happening but I suspect is has something to do with page_load and IsPostBack.
The page has a form that displays a record. The user can delete the record by clicking a delete button or update it by clicking an update button. The delete sub calls a couple of other subs and functions and then displays a confirmation message or an error. In my case...it's doing BOTH. I had another classic VB developer look over it with me and we're both stumped.
I would love to post a URL but this still in early development and not live. We even put temp counters in place and wrote them to the page and the delete sub is indeed running twice. It deletes the record just fine and then runs again and displays the error message since the MS SQL didn't delete the record successfully (a second time).
Surely, I must be missing something obvious. Help is much appreciated!! The person who figures this out gets a lifetime membership card to Hooters. =) I've had this sort of behaviour in the past when I'm using VBs Handles clause (as you are using), but also stupidly called AddHandler with the same event and function. Do you use AddHandler? Or do you have AutoEventWireup set to true or absent in your aspx page? (Not sure about this last - having never used it)
Damien
ShaneFowlkes wrote: I'll be d@mned. I removed "Handles btnDelete.Click " from the sub and it worked fine.
Is this a .NET2 bug? The "Handles" came from VS/VWD itself. I just dbl clicked the asp:button to start building the sub. I never added it before when coding by hand.
What cause this behavior? Why would it fire twice?
PS - THANK YOU.
Hi Shane,
I have to admit, I'm still not developing in 2.0 yet (Most of our apps
are part of ONE BIG APPLICATION in 1.1, so until we migrate the whole
lot, I'm stuck with it).
I can only imagine that something, somewhere is calling AddHandler for
you.
I could only find one similar bug report at the product feedback
centre: http://lab.msdn.microsoft.com/produc...2-8cc11498c1d0
but if that's not what you're doing then I don't know.
Sorry I can't be of more assistance,
Damien This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
Hello to all
I'm handling the Validating event for one text box.
If something is wrong in user input I show a warning message.
The problem is that if I add to method the message is
displayed twice (event fired twice).
Without event is fired once.
if(txtMSG.Length > 0)
{
|
by: Seraph |
last post by:
Again, I'm rather new here, so if I fail to follow any etiquette,
please forgive me and let me know what I've done wrong, but I think
this might interest quite a few people.
One of my colleaques was endeavoring to create a custom user control to
make things a bit simpler, but she noticed that her Page_Load
eventhandler was firing twice. So after long hours of research and
experimentation, I stumbled upon, imho, is quite the discovery.
...
|
by: Matthew |
last post by:
All,
I have searched google and the newsgroups but can't find anything the
same as what I am experiencing (though I may have missed something).
I have controls (textboxes) within UserControls which are not behaving
as I would expect. Specifically, if there is a command button external
to the usercontrol which is activated by a shortcut key (eg Alt-B),
the command button Click event handler code 'executes' even though the
textbox set...
|
by: Diana |
last post by:
I've got a database that has been working successfully for a number of
years now. I just added a new item - basically a field that becomes
visible depending on another field's value. When I was testing this, I
noticed that the OnCurrent event wasn't firing. I went to an older
version of the program and saw that it wasn't firing there either. I
don't know how long this has been going on, but it's quite distressing.
To test the firing, I...
|
by: TS |
last post by:
I have this custom data list control and i override the onItemDatabound
event. After upgrading to vs 2005, this event is not always getting called,
though it does at other times. No changes were made when upgrading to 2.0
is there any reason for this because of .net 2.0?
thanks
| |
by: John Kotuby |
last post by:
Hi guys,
I am converting a rather complicated database driven Web application from
classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The
original ASP application works quite well, so at times it is tempting just
to port parts of it over mostly as-is. In fact, one MSDN article I read
suggested using straight HTML wherever possible to make the app more
efficient and less resource demanding.
On one page there are 2...
|
by: joaotsetsemoita |
last post by:
Hello everyone,
I'm having troubles assigning an onclick event to a cell. Im trying
something like
cursorPoint.cells.style.cursor = "hand";
cursorPoint.cells.width = "20";
cursorPoint.cells.onclick = "alert('this is a test');"
cursorPoint.cells.alt = "Select the columns";
cursorPoint.cells.innerHTML = " "
|
by: =?Utf-8?B?SGV6YWw=?= |
last post by:
Hi,
I am trying to add a new record to a table but everytime I click the button,
somehow it saves the record twice...
I've created a stored procedure to insert records into a table and I called
that procedure in the code that I attached to a button click.
Here is the event handler code which is created automatically:
this.AddCustomer.Click += new System.EventHandler(this.AddCustomer_Click);
I checked the stored procedure and the code...
|
by: =?Utf-8?B?QmFycnkgR2lsYmVydA==?= |
last post by:
I have a class that raises events that downstream objects subscribe to. In
one case, after destroying the object, the event seems to still get handled
in a subscriber object. So I instantiate an object and the event fires
correctly. Then I destroy the object and instantiate another instance and the
subscriber event handler get hit twice. I've tried using IDisposible and also
using GC.Collect, but it didn't seem to help. I've also tried...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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
| |