help please on GridView commands + AutoEventWireUp, firing twice etc...

help please on GridView commands + AutoEventWireUp, firing twice etc...

am 16.12.2005 19:41:19 von Tim_Mac

hi,
i'm new to .net 2.0, and am just starting to get to grips with the
gridview.
my page has autoEventWireUp set to true, which i gather is supposed to
figure out which handlers to invoke when appropriate based on your
method names .
the GridView has OnRowCommand="GridView1_RowCommand" in the aspx.

my problem is that the RowCommand event is firing twice (95% of the
time) on the page. the other 5% it only fires once. there's no
consistency at all.

in .net 1.1, i would have understood that the code-behind was wiring up
the event, and the aspx was doing the same thing, so this would result
in the event being raised twice. however, in .net 2, i can't find any
code-behind that would be doing this (even looked in temp.asp.net
files).

if i set autoEventWireUp=true, with the OnRowCommand declared in the
GridView aspx, Page_Load fires twice, so does GridView1_RowCommand.

if i set AutoEventWireup=false, PageLoad doesn't fire (as is expected)
and GridView1_RowCommand only fires once. but occassionally it fires
twice. this is painful! somebody please put me out of my misery :-)

here is my code:
******** ASPX *********
<%@ Page Language="C#" AutoEventWireup="false"
CodeFile="TestGridView.aspx.cs" Inherits="Admin_TestGridView" %>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">




AutoGenerateColumns="False" DataKeyNames="PageID"
DataSourceID="dsPages"
OnRowCommand="GridView1_RowCommand">

HeaderText="Title" />
CommandName="MoveUp" ImageUrl="../Images/Move_Up.gif"
Text="Move this page up one position" />
CommandName="MoveDown" ImageUrl="../Images/Move_Down.gif"
Text="Move this page down one position" />


SelectMethod="Select" TypeName="PageManager">






********** CODE BEHIND ***********
public partial class Admin_TestGridView : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Page_Load
");
}

protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
Response.Write("GridView1_RowCommand
");
}
}

what i did was put break-points in both events, debug, and keep
clicking the up/down buttons until you see the event hit twice for one
click.

thank you
tim

RE: help please on GridView commands + AutoEventWireUp, firing twice e

am 16.12.2005 20:56:02 von Phillip.Williams

Hi tim,

You do not need to specify the OnRowCommand if you have the autoEventWireUp
=true.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Tim_Mac" wrote:

> hi,
> i'm new to .net 2.0, and am just starting to get to grips with the
> gridview.
> my page has autoEventWireUp set to true, which i gather is supposed to
> figure out which handlers to invoke when appropriate based on your
> method names .
> the GridView has OnRowCommand="GridView1_RowCommand" in the aspx.
>
> my problem is that the RowCommand event is firing twice (95% of the
> time) on the page. the other 5% it only fires once. there's no
> consistency at all.
>
> in .net 1.1, i would have understood that the code-behind was wiring up
> the event, and the aspx was doing the same thing, so this would result
> in the event being raised twice. however, in .net 2, i can't find any
> code-behind that would be doing this (even looked in temp.asp.net
> files).
>
> if i set autoEventWireUp=true, with the OnRowCommand declared in the
> GridView aspx, Page_Load fires twice, so does GridView1_RowCommand.
>
> if i set AutoEventWireup=false, PageLoad doesn't fire (as is expected)
> and GridView1_RowCommand only fires once. but occassionally it fires
> twice. this is painful! somebody please put me out of my misery :-)
>
> here is my code:
> ******** ASPX *********
> <%@ Page Language="C#" AutoEventWireup="false"
> CodeFile="TestGridView.aspx.cs" Inherits="Admin_TestGridView" %>
>
> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
>
>


>

> > AutoGenerateColumns="False" DataKeyNames="PageID"
> DataSourceID="dsPages"
> OnRowCommand="GridView1_RowCommand">
>
> > HeaderText="Title" />
> > CommandName="MoveUp" ImageUrl="../Images/Move_Up.gif"
> Text="Move this page up one position" />
> > CommandName="MoveDown" ImageUrl="../Images/Move_Down.gif"
> Text="Move this page down one position" />
>

>

> > SelectMethod="Select" TypeName="PageManager">
>

>
>
>
>
>
> ********** CODE BEHIND ***********
> public partial class Admin_TestGridView : System.Web.UI.Page
> {
> protected void Page_Load(object sender, EventArgs e)
> {
> Response.Write("Page_Load
");
> }
>
> protected void GridView1_RowCommand(object sender,
> GridViewCommandEventArgs e)
> {
> Response.Write("GridView1_RowCommand
");
> }
> }
>
> what i did was put break-points in both events, debug, and keep
> clicking the up/down buttons until you see the event hit twice for one
> click.
>
> thank you
> tim
>
>

Re: help please on GridView commands + AutoEventWireUp, firing twice e

am 18.12.2005 20:42:13 von Tim_Mac

hi Philip, thanks for the reply.
ok so that is what's supposed to happen, i would agree with you.
except... when i set autoEventWireUp=true, the GridView1_RowCommand
event is not raised at all when i click one of the button fields, and
Page_Load fires twice when i click the button. it only fires once when
the page is first loaded.

the code i'm using is the exact same as posted above, except
OnRowCommand has been removed from the gridView aspx, and
autoEventWireUp has been changed to true.

why would Page_Load fire twice, and why does autoEventWireUp not do
it's job in hooking up my RowCommand event handler?

thanks
tim

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 19.12.2005 05:34:02 von Phillip.Williams

Hi Tim,

Thanks for responding. This discussion got me to correct some of my
misconceptions about the AutoEventWireUp property.

Here is what I found by researching the topic:
1- The AutoEventWireUp applies only to the page events. For an explanation
of the page events:
http://msdn2.microsoft.com/en-us/library/ms178472(en-US,VS.8 0).aspx
2- You have to wire up the events for the controls within the page even if
you have the AutoEventWireUp=true. The VS.Net does that automatically when
you double click on a control by adding markup for you within the server
control.

To verify my findings, I created 3 demos out of the code that you posted
earlier:
1- In this demo the AutoEventWireUp is set to true and the event fire up
twice because I have also overridden the OnInit method and put event wiring
for controls in it
http://www.webswapp.com/CodeSamples/aspnet20/AutoEventWireUp _True_Error.aspx

2- In this demo the AutoEventWireUp is set to true and everything works as
expected
http://www.webswapp.com/CodeSamples/aspnet20/AutoEventWireUp _True.aspx

3- In this demo the AutoEventWireUp is set to false (my preference in
programming because it improves performance) and everything works as expected
http://www.webswapp.com/CodeSamples/aspnet20/AutoEventWireUp _False.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Tim_Mac" wrote:

> hi Philip, thanks for the reply.
> ok so that is what's supposed to happen, i would agree with you.
> except... when i set autoEventWireUp=true, the GridView1_RowCommand
> event is not raised at all when i click one of the button fields, and
> Page_Load fires twice when i click the button. it only fires once when
> the page is first loaded.
>
> the code i'm using is the exact same as posted above, except
> OnRowCommand has been removed from the gridView aspx, and
> autoEventWireUp has been changed to true.
>
> why would Page_Load fire twice, and why does autoEventWireUp not do
> it's job in hooking up my RowCommand event handler?
>
> thanks
> tim
>
>

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 19.12.2005 08:27:25 von stcheng

Hi Tim,

As for ASP.NET 2.0's new page compilation model, the AutoWireupEvent is no
longer turn off by default in VS2005 web project IDE. And the page's
AutoEventWireup should only apply to page's events rather than any other
server controls' events. So if we have the page's AutoEventWireup set to
"false" and we don't explicitly register Page_load function for page, and
also dosn't add GridView's RowCommand event handler in the aspx template,
neither event handler should be fired.....

so for your scenario, I think it should be an page specific or environment
specific problem. Here is test page I used on myside which works as
expected:(I also use the page's OutputTrace to print the event handler
exection time.....)

#when AutoWireupEvent turn off, Page_Load not executed , but RowCommand
still work since it is delcared through aspx template's control attribute

#when AutoWireupEvent turn on, both event handler get executed and only
once.....

You can have a test through it to see whether it also encounter the problem:

=========aspx==========
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="EventWireupPage.aspx.cs" Inherits="EventWireupPage" Trace="true"
%>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Untitled Page




ConnectionString="<%$ ConnectionStrings:LocalNorthWind %>"
SelectCommand="SELECT [CategoryID], [CategoryName],
[Description] FROM [Categories]">

AutoGenerateColumns="False" DataKeyNames="CategoryID"
DataSourceID="SqlDataSource1"
OnRowCommand="GridView1_RowCommand">

HeaderText="CategoryID" InsertVisible="False"
ReadOnly="True" SortExpression="CategoryID" />
HeaderText="CategoryName" SortExpression="CategoryName" />
HeaderText="Description" SortExpression="Description" />










==========code behind==========
public partial class EventWireupPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Trace.Write("Page_load " + DateTime.Now.ToLongTimeString() );
}
protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
Trace.Write("RowCommand " + e.CommandName + " " +
DateTime.Now.ToLongTimeString());
}
}
====================

Please feel free to post here when you have any furhter finding or need any
assistance.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Thread-Topic: help please on GridView commands + AutoEventWireUp, firing
twi
| thread-index: AcYEVW+3hSkc5a7PT+ar2/nTIb7cww==
| X-WBNR-Posting-Host: 70.68.38.48
| From: "=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?="

| References: <1134758479.753635.111210@z14g2000cwz.googlegroups.com>

<1134934933.015121.117450@g44g2000cwa.googlegroups.com>
| Subject: Re: help please on GridView commands + AutoEventWireUp, firing
twi
| Date: Sun, 18 Dec 2005 20:34:02 -0800
| Lines: 56
| Message-ID:
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx .gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:365626
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi Tim,
|
| Thanks for responding. This discussion got me to correct some of my
| misconceptions about the AutoEventWireUp property.
|
| Here is what I found by researching the topic:
| 1- The AutoEventWireUp applies only to the page events. For an
explanation
| of the page events:
| http://msdn2.microsoft.com/en-us/library/ms178472(en-US,VS.8 0).aspx
| 2- You have to wire up the events for the controls within the page even
if
| you have the AutoEventWireUp=true. The VS.Net does that automatically
when
| you double click on a control by adding markup for you within the server
| control.
|
| To verify my findings, I created 3 demos out of the code that you posted
| earlier:
| 1- In this demo the AutoEventWireUp is set to true and the event fire up
| twice because I have also overridden the OnInit method and put event
wiring
| for controls in it
|
http://www.webswapp.com/CodeSamples/aspnet20/AutoEventWireUp _True_Error.aspx
|
| 2- In this demo the AutoEventWireUp is set to true and everything works
as
| expected
| http://www.webswapp.com/CodeSamples/aspnet20/AutoEventWireUp _True.aspx
|
| 3- In this demo the AutoEventWireUp is set to false (my preference in
| programming because it improves performance) and everything works as
expected
| http://www.webswapp.com/CodeSamples/aspnet20/AutoEventWireUp _False.aspx
|
| --
| HTH,
| Phillip Williams
| http://www.societopia.net
| http://www.webswapp.com
|
|
| "Tim_Mac" wrote:
|
| > hi Philip, thanks for the reply.
| > ok so that is what's supposed to happen, i would agree with you.
| > except... when i set autoEventWireUp=true, the GridView1_RowCommand
| > event is not raised at all when i click one of the button fields, and
| > Page_Load fires twice when i click the button. it only fires once when
| > the page is first loaded.
| >
| > the code i'm using is the exact same as posted above, except
| > OnRowCommand has been removed from the gridView aspx, and
| > autoEventWireUp has been changed to true.
| >
| > why would Page_Load fire twice, and why does autoEventWireUp not do
| > it's job in hooking up my RowCommand event handler?
| >
| > thanks
| > tim
| >
| >
|

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 19.12.2005 12:56:12 von Tim_Mac

philip, many thanks for the examples.
steven, thanks also for the reply. i have narrowed down my problem,
and i am quite sure at this stage that i have encountered a bizarre
behaviour/bug/feature/whatever.

if you take your sample page that you made, and add the following
attributes to the 2 button fields:
ButtonType="image" ImageUrl="MoveUp.gif"

if you debug your code then, you will see Page_Load gets invoked twice,
and so does RowCommand. that's the only change i made, and when i go
back to your original version with the text/button columns, it works
fine. this is an empty web project with one aspx page so there are no
unusual config problems.

it is very frustrating!! i hope you can shed some light on this
behaviour.
thanks
tim

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 20.12.2005 11:24:55 von stcheng

Hey Tim,

Thanks for your quick response.
I've just made some further test according to the change you mentioened,
below is my modiied page's aspx template:

However, I still only get the Page_Load or GridView_OnRowCommand fire
once.... Would you please attache a complete project that contains such a
reproduce page in it so that I can test through the complete project on
myside?


========aspx==========
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="EventWireupPage.aspx.cs" Inherits="EventWireupPage" Trace="false"
%>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Untitled Page




ConnectionString="<%$ ConnectionStrings:LocalNorthWind %>"
SelectCommand="SELECT [CategoryID], [CategoryName],
[Description] FROM [Categories]">

AutoGenerateColumns="False" DataKeyNames="CategoryID"
DataSourceID="SqlDataSource1"
OnRowCommand="GridView1_RowCommand">

HeaderText="CategoryID" InsertVisible="False"
ReadOnly="True" SortExpression="CategoryID" />
HeaderText="CategoryName" SortExpression="CategoryName" />
HeaderText="Description" SortExpression="Description" />
ImageUrl="~/Images/menu_pop_dynamic.GIF" Text="MoveUp" />
ImageUrl="~/Images/menu_pop_static.GIF" Text="MoveDown" />







====================================

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "Tim_Mac"
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Subject: Re: help please on GridView commands + AutoEventWireUp, firing
twi
| Date: 19 Dec 2005 03:56:12 -0800
| Organization: http://groups.google.com
| Lines: 20
| Message-ID: <1134993372.705268.137110@f14g2000cwb.googlegroups.com>
| References: <1134758479.753635.111210@z14g2000cwz.googlegroups.com>
|
| <1134934933.015121.117450@g44g2000cwa.googlegroups.com>
|
|
| NNTP-Posting-Host: 83.141.121.205
| Mime-Version: 1.0
| Content-Type: text/plain; charset="iso-8859-1"
| X-Trace: posting.google.com 1134993378 19451 127.0.0.1 (19 Dec 2005
11:56:18 GMT)
| X-Complaints-To: groups-abuse@google.com
| NNTP-Posting-Date: Mon, 19 Dec 2005 11:56:18 +0000 (UTC)
| In-Reply-To:
| User-Agent: G2/0.2
| X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8)
Gecko/20051111 Firefox/1.5,gzip(gfe),gzip(gfe)
| Complaints-To: groups-abuse@google.com
| Injection-Info: f14g2000cwb.googlegroups.com; posting-host=83.141.121.205;
| posting-account=UaxKfw0AAAA4oMLJHydK195yIv1avAma
| Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t- online.de!t-onli
ne.de!news.glorb.com!postnews.google.com!f14g2000cwb.googleg roups.com!not-fo
r-mail
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:365670
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| philip, many thanks for the examples.
| steven, thanks also for the reply. i have narrowed down my problem,
| and i am quite sure at this stage that i have encountered a bizarre
| behaviour/bug/feature/whatever.
|
| if you take your sample page that you made, and add the following
| attributes to the 2 button fields:
| ButtonType="image" ImageUrl="MoveUp.gif"
|
| if you debug your code then, you will see Page_Load gets invoked twice,
| and so does RowCommand. that's the only change i made, and when i go
| back to your original version with the text/button columns, it works
| fine. this is an empty web project with one aspx page so there are no
| unusual config problems.
|
| it is very frustrating!! i hope you can shed some light on this
| behaviour.
| thanks
| tim
|
|

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 20.12.2005 14:03:45 von Tim_Mac

hi Steven,
i sent the solution to your newsgroup email address without the
'online'. hope it gets through.
thanks
tim

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 21.12.2005 14:02:36 von stcheng

Hi Tim,

I have tested the project you sent me, however, it seems that I still get
the Page_Load and GridView's OnRowCommand event handler fired once (page's
AutoWireupEvent turn on). Have you checked the IIS log when you performing
the gridView's postback command to see whether there're any other log
entries mapped to that page?
Also, if possible, you can also try the same page on some other machine or
create a new project to perform the same test...

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| From: "Tim_Mac"
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Subject: Re: help please on GridView commands + AutoEventWireUp, firing
twi
| Date: 20 Dec 2005 05:03:45 -0800
| Organization: http://groups.google.com
| Lines: 6
| Message-ID: <1135083825.482271.39480@z14g2000cwz.googlegroups.com>
| References: <1134758479.753635.111210@z14g2000cwz.googlegroups.com>
| <1134993372.705268.137110@f14g2000cwb.googlegroups.com>
| <18otl#UBGHA.2560@TK2MSFTNGXA02.phx.gbl>
| NNTP-Posting-Host: 83.141.121.205
| Mime-Version: 1.0
| Content-Type: text/plain; charset="iso-8859-1"
| X-Trace: posting.google.com 1135083830 5044 127.0.0.1 (20 Dec 2005
13:03:50 GMT)
| X-Complaints-To: groups-abuse@google.com
| NNTP-Posting-Date: Tue, 20 Dec 2005 13:03:50 +0000 (UTC)
| In-Reply-To: <18otl#UBGHA.2560@TK2MSFTNGXA02.phx.gbl>
| User-Agent: G2/0.2
| X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8)
Gecko/20051111 Firefox/1.5,gzip(gfe),gzip(gfe)
| Complaints-To: groups-abuse@google.com
| Injection-Info: z14g2000cwz.googlegroups.com; posting-host=83.141.121.205;
| posting-account=UaxKfw0AAAA4oMLJHydK195yIv1avAma
| Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t- online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!border1.nntp.dca.giganew s.com!nntp.gigan
ews.com!postnews.google.com!z14g2000cwz.googlegroups.com!not -for-mail
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:365929
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| hi Steven,
| i sent the solution to your newsgroup email address without the
| 'online'. hope it gets through.
| thanks
| tim
|
|

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 21.12.2005 16:10:38 von Tim_Mac

hi Steven,
thanks for continuing to look into it. i have just tried it on my
production server, windows 2003 enterrprise, asp.net 2. and i get the
same behaviour, double events for postback.
i found the system log to be a reliable way to record the behaviour of
each event execution. this rules out any debugger anomalies etc.

the output from the IIS log shows the double requests. the log
activity consists of one access to the page, followed by a click on the
move-down button, which as you can see triggers two POST events at the
same time, both with IIS status 200.

#Fields: date time cs-method cs-uri-stem cs-uri-query s-port
cs-username c-ip cs-version cs(User-Agent) sc-status sc-substatus
sc-win32-status sc-bytes
2005-12-21 14:58:57 GET /EventWireupPage.aspx - 8090 - xx.yyy.zzz.zzz
HTTP/1.1
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET +CLR+1.1.4322;+.NET+CLR+2.0.50727)
200 0 0 35998
2005-12-21 14:58:57 GET /MoveDown.gif - 8090 - xx.yyy.zzz.zzz HTTP/1.1
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET +CLR+1.1.4322;+.NET+CLR+2.0.50727)
404 0 2 1795
2005-12-21 14:59:00 POST /EventWireupPage.aspx - 8090 - xx.yyy.zzz.zzz
HTTP/1.1
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET +CLR+1.1.4322;+.NET+CLR+2.0.50727)
200 0 64 0
2005-12-21 14:59:00 POST /EventWireupPage.aspx - 8090 - xx.yyy.zzz.zzz
HTTP/1.1
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET +CLR+1.1.4322;+.NET+CLR+2.0.50727)
200 0 0 39927
2005-12-21 14:59:00 GET /MoveDown.gif - 8090 - xx.yyy.zzz.zzz HTTP/1.1
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET +CLR+1.1.4322;+.NET+CLR+2.0.50727)
404 0 2 1795

my updated code is below, i didn't make any other changes:
public partial class EventWireupPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Diagnostics.EventLog.WriteEntry("ASPNET", "Page_Load");
}

protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
System.Diagnostics.EventLog.WriteEntry("ASPNET",
"GridView1_RowCommand");
}
}

by the way, the only way i noticed it was because of a swap routine
with the move up/down buttons, which obviously when you execute the
same swap twice, it does not change the ordering of the items. if you
use tracing it only shows the trace for one of the postbacks, and
similarly response.Write does not help, so the event log is a sure way
to track it. the event log shows an event for Page_Load corresponding
to the first page access, then there are 2 Page_Load events and 2
RowCommand events, corresponding to the postback(s).

i'm grateful for any more clues you may have to try and get to the
bottom of this.
thanks
tim

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 21.12.2005 18:09:18 von Tim_Mac

just to add to the melting pot, i noticed the "sc-win32-status" value
is 64 for the first bogus postback, i say the first one is bogus
because it has 0 bytes size. but it definitely executes on the server.
i did some hunting around on google for sc-win32-status 64, and i found
many unresolved posts of people reporting problems, some relating to
postback, with this type of log entry.

http://groups.google.com/groups?q=sc-win32-status+64&qt_s=Se arch

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 23.12.2005 13:54:51 von stcheng

Thanks for your response Tim,

It sounds very strange that there occurs two requests each time (since the
IIS log shows two POST entries each time....), I've also discussed with
our IIS engineer, I think we may need to use some http or TCP trace tool to
capture the two requests... Is the "two request" behavior always occuring
both when we request the page from local server or from a remote client
machine?

There're some http/tcp trace tools like the Trace Utility in soap toolkit
or tcptrace....:

SOAP TOOLKIT 3.0
http://www.microsoft.com/downloads/details.aspx?FamilyId=C94 3C0DD-CEEC-4088-
9753-86F052EC8450&displaylang=en

tcptrace
http://www.pocketsoap.com/tcptrace/

Also, if you have any other trace tools which can catpure http request,
that'll be ok. We need to capture the http message's content to see what's
the difference between them. Also, if the problem also occur on other
remote client, we can also confirm whether the two request are caused by
client browser or serverside....

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "Tim_Mac"
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Subject: Re: help please on GridView commands + AutoEventWireUp, firing
twi
| Date: 21 Dec 2005 09:09:18 -0800
| Organization: http://groups.google.com
| Lines: 9
| Message-ID: <1135184958.516902.139660@z14g2000cwz.googlegroups.com>
| References: <1134758479.753635.111210@z14g2000cwz.googlegroups.com>
| <1135083825.482271.39480@z14g2000cwz.googlegroups.com>
|
| <1135177838.689659.310980@g49g2000cwa.googlegroups.com>
| NNTP-Posting-Host: 83.141.121.205
| Mime-Version: 1.0
| Content-Type: text/plain; charset="iso-8859-1"
| X-Trace: posting.google.com 1135184963 5422 127.0.0.1 (21 Dec 2005
17:09:23 GMT)
| X-Complaints-To: groups-abuse@google.com
| NNTP-Posting-Date: Wed, 21 Dec 2005 17:09:23 +0000 (UTC)
| In-Reply-To: <1135177838.689659.310980@g49g2000cwa.googlegroups.com>
| User-Agent: G2/0.2
| X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8)
Gecko/20051111 Firefox/1.5,gzip(gfe),gzip(gfe)
| Complaints-To: groups-abuse@google.com
| Injection-Info: z14g2000cwz.googlegroups.com; posting-host=83.141.121.205;
| posting-account=UaxKfw0AAAA4oMLJHydK195yIv1avAma
| Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t- online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!border1.nntp.dca.giganew s.com!nntp.gigan
ews.com!postnews.google.com!z14g2000cwz.googlegroups.com!not -for-mail
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:366303
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| just to add to the melting pot, i noticed the "sc-win32-status" value
| is 64 for the first bogus postback, i say the first one is bogus
| because it has 0 bytes size. but it definitely executes on the server.
| i did some hunting around on google for sc-win32-status 64, and i found
| many unresolved posts of people reporting problems, some relating to
| postback, with this type of log entry.
|
| http://groups.google.com/groups?q=sc-win32-status+64&qt_s=Se arch
|
|

Re: help please on GridView commands + AutoEventWireUp, firing twice

am 04.01.2006 20:11:34 von Tim_Mac

hi Steven,
thanks for the reply. yes it does happen while browsing remotely or
locally. but i can only reproduce the double-postback in IE6. it
never happens in IE5.0 (tested on windows 2000) or FireFox 1.5. my IE
and FF testing is on a fully up-to-date XP pro sp2.

i set up TcpTrace, and recorded 2 different log files, one while
browsing with IE6, and the other with FF. you can download them here:
http://tim.mackey.ie/stuff/IE_dud_postback.xml
http://tim.mackey.ie/stuff/FF_OK_PostBack.xml

The first file "IE_Dud_postback" shows 5 connections, i will summarise
below:
+ GET aspx page
+ GET the image
+ POST aspx page, note that bytes are sent but no bytes are received
back by the client
+ POST aspx page, this is the second postback, which gets a response
from the server.
+ GET the image

from debugging and event logging etc, i am 100% certain that .Net
executes Page_Load and GridView_RowCommand for both of those postbacks.
i'm using the same code as i posted previously.

the firefox sequence of events is as expected, only one postback. this
only seems to happen on ButtonField's with ButtonType="Image"

is there any more information i can provide? if i found a really big
bug do i get a prize? :)

tim

Re: help please on GridView commands + AutoEventWireUp, firing twice

am 11.01.2006 17:01:22 von Weaver

Hi all,

Just to let you know, Tim, that YOU ARE NOT ALONE!!! We've been
developping Web applications with .NET 2.0 and are struggling with the
same undocumented features.

The workaround we are using is based on the fact that the correct
request includes the same POST-data of the first request together with
extra values. These values are coordinates of the click on the image of
the ButtonField, if you are using the ButtonType set to Image, ofcourse.



To detect the second / good post, you can simply check the presence of
the Request-variables "x" and "y":

if(this.Request["x"]==null || this.Request["y"]==null)
{ // This is fake }

These variables should contain integer-positions of the click on the
image and this is the behavior in FireFox, Opera and Internet Explorer.
We didn't test on other clients nor systems, though.

Any decent way to avoid this problem is welcome!

I hope this can help you and I hope Steven can give us an official tip!

Wim


*** Sent via Developersdex http://www.developersdex.com ***

Re: help please on GridView commands + AutoEventWireUp, firing twice

am 11.01.2006 22:58:25 von Tim_Mac

hi wim, what a great work-around!!
thank you so much for posting this. hopefully Steven will be back from
newsgroup holidays soon :)

Re: help please on GridView commands + AutoEventWireUp, firing twice

am 13.01.2006 13:16:10 von Tim_Mac

just to add to my previous post, the code wim posted should only be
included for ButtonFields with type="image". so don't put it in your
Page_Load or it will interfere with normal postbacks for other buttons
on the page etc.
as well as this, make sure you don't use the code with a LinkButton
inside a TemplateField, as it may kill the correct postback.

a sample of the scenario where i use the work-around code is as
follows:

protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
switch (e.CommandName)
{
case "MoveUp":
// check for bogus postback from ImageButton
if(this.Request["x"] == null && this.Request["y"] == null)
Response.End();
....

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 01.02.2006 11:09:26 von manuel0081

Hi all, i have the same problem
I note that the first request is 8 byte less than the second. I think
they are X=... and Y=...

I appreciates the solution if(...=null..&& ..=null)
but i think it's not possible. If it's a bug microsoft have to solve!


Ema

*** Sent via Developersdex http://www.developersdex.com ***

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 01.02.2006 16:12:24 von Weaver

Ema,

Yes, the request is at least 8 bytes longer, depending on the image
coordinates. The querystring for small coordinates (lower then 10) is
for example: &x=5&y=7. This means an increase of 8 bytes. If the
coordinates are heigher, this will result in more bytes, eg. &x=14&y=30
is a total of 10 bytes.

The quick-hack work-around unprofessional solution is not acceptable,
but we are waiting for any comments from Microsoft! Go Bill, go Bill!

Greetings,
Wim Verbeke


*** Sent via Developersdex http://www.developersdex.com ***

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 03.02.2006 09:37:20 von manuel0081

Hi,
1.I'm looking also gridview_rowEditing and i have the same problem. I
have not it on RowDeleting (i don't know why)

Have someone understood when it happens (for me it is random!)??

2.If it's related with imagebutton why I haven't using only imagebutton
without gridview?

Ema

*** Sent via Developersdex http://www.developersdex.com ***

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 03.02.2006 11:06:16 von manuel0081

I would tell you that the previous solution is not good if i'm
implementing moveup/down,edit and cancel(all imagebutton with
commandname).
It seems code executes Rowcommand and then RowEditing/RowDeleting. If
you use that code, then delete doesn't work properly (i add to my button
javascript to confirm). So i use:

if (Request["x"] == null && Request["y"] == null && (e.CommandName ==
"MoveUp" || e.CommandName == "MoveDown"))
Response.End();

In RowEditing i use:
if (Request["x"] == null && Request["y"] == null)
Response.End();


Ema

*** Sent via Developersdex http://www.developersdex.com ***

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 08.02.2006 08:43:11 von manuel0081

up to attention...

Ema

*** Sent via Developersdex http://www.developersdex.com ***

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 15.02.2006 14:30:13 von manuel0081

noone answer to this threaD?

Ema

*** Sent via Developersdex http://www.developersdex.com ***

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 15.02.2006 15:06:27 von Tim_Mac

i've reposted the problem due to lack of response on this thread. i
am awaiting a reply from an MS guy. the new thread is at
http://groups.google.com/group/microsoft.public.dotnet.frame work.aspnet/browse_frm/thread/d32e4efa2d10e573

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 23.02.2006 18:20:14 von Charm Lor

Does anyone have an update on this issue? I'm running into the same
thing. Random multiple POSTs causing duplicate charges/credits for
clients. Subsequent POSTs are sent when the first POST receives a 200 0
64 response. Users swear they did not click the Submit button twice.





*** Sent via Developersdex http://www.developersdex.com ***

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 24.02.2006 08:42:06 von manuel0081

This bug has been forwarded to Microsoft.
This is the answer from Microsoft Bug adn reported issues:

Thanks for reporting the issue. This is a known issue and we are
investigating fixing this in the next service pack. For the time being
you could use the following work around. One obvious workaround is to
change the button type to a regular button or a link button. If you need
an ImageButton, then you can put an ImageButton in a TemplateField. You
may need to handle the Command event on the ImageButton and call
DeleteRow, passing the RowIndex as the CommandArgument, like this:





ImageUrl="..." CommandArgument='<%# DataBinder.Eval(Container,
"RowIndex") %>' OnCommand="ImageButton1_Command" />





protected void ImageButton1_Command(object sender, CommandEventArgs e) {
GridView1.DeleteRow(Int32.Parse(e.CommandArgument.ToString() ));
}

Thanks,
The Web Platform and Tools Team


You can find discussion in the site in the previous post or to
http://forum.aspitalia.com/forum/post/259149/GridviewImagebu tton.aspx


Ema

*** Sent via Developersdex http://www.developersdex.com ***

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 06.02.2007 16:55:18 von JHirsch

Another request for microsoft to provide an official reply. I can verify
the exact behavior describe and add the following. This occurs only in
IE (v. 6 and v. 7). Additionally it occurs on both IIS5 and IIS6, as
well as the local Cassini server.


*** Sent via Developersdex http://www.developersdex.com ***

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 07.02.2007 07:36:04 von stcheng

Hello JHirsch,

Is the Gridview command issue you mentioned here means the double postback
behavior of ImageButton in GridView command field? So far, there is only an
existing issue of this. You can have a look at the following newsgroup
thread to see whether the problem you met is exact the one there:

http://groups.google.com/group/microsoft.public.dotnet.frame work.aspnet.webc
ontrols/browse_thread/thread/a9a1bd53c27bd8b0/82c51830597e5f c8

Also, for this issue, there is already a public bug entry on the product
feedback center(also recorded in internal bug database):

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedb ack.aspx?Feedbac
kid=105123

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

Re: help please on GridView commands + AutoEventWireUp, firing twi

am 09.02.2007 02:45:05 von stcheng

Hello JHirsch,

Is the bug entry I posted in last message the one meet your scenario?
Please feel free to let me know if there is anything else we can help.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.