pedestrian via DotNetMonster.com wrote:
Quote:
(Default.aspx)
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb"
Inherits="_Default" Trace="true"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnAdd" Text="Add" OnClick="btnAdd_Click"
runat="server" />
<asp:Label ID="lblCounter" Text="0" runat="server" />
</div>
</form>
</body>
</html>
>
(Default.aspx.vb)
Partial Class _Default
Inherits System.Web.UI.Page
>
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.
EventArgs) Handles btnAdd.Click
Trace.Warn("Before add: " & lblCounter.Text)
lblCounter.Text = (Int32.Parse(lblCounter.Text) + 1).ToString
Trace.Warn("After add: " & lblCounter.Text)
End Sub
End Class
>
--
Regards,
Pedestrian, Penang.
AutoEventWireup="true" - Find all of the <control name>_<event name>
methods add attach them to the <control name>.<event nameevent
Handles <control name>.<event name- Attach this method to the
<control name>.<event nameevent.
So your btnAdd_Click method is being attached to the btnAdd.Click event
twice, and is hence being called twice. My normal advice would be to
set AutoEventWireup to false.
Damien