Saturday, March 31, 2012

Strange Behavior

Hi All,
I have a webapp page that gathers a bunch of parameters and then saves the parameters into a session variable (as an object). The code then redirects via Response.Redirect() to a new page. The new page then renders a chart based on the values stored in the session variable. On the resulting page I have a button that redirects back to the original page with the form. I'm doing this as follows: Response.Redirect("Frm_KPI.aspx?redo=1");
In the Page_Load() method in "Frm_KPI.aspx.cs" I have the following code:

protectedvoid Page_Load(object sender, System.EventArgs e)

{

//

// Initialize the database connection

//

InitDB();

// Check the query string to see if user wants to reload the form.

if (Quartz_QueryString("redo") =="1")

{

//

// User wants to reload the form from the Session parameter object

//

m_Params = (CKPIParameters)Session["KPI_PARAMS"];

InitJobTypeList(true);

InitJobOwnerList(true);

InitTimingParameters(true);

InitInterval(true);

InitTimeBase(true);

InitNormalizeBy(true);

InitJobPriorityList(m_Params.JobType,true);

InitJobAnalysisMode(m_Params.JobType,true);

InitJobAnalysisHistory(m_Params.JobType,true);

}

else

{

if (!IsPostBack)

{

m_Params.JobType ="SEM";

InitJobTypeList(false);

InitJobOwnerList(false);

InitTimingParameters(false);

InitInterval(false);

InitTimeBase(false);

InitNormalizeBy(false);

InitJobPriorityList(m_Params.JobType,false);

InitJobAnalysisMode(m_Params.JobType,false);

InitJobAnalysisHistory(m_Params.JobType,false);

m_hplStartDate.NavigateUrl ="javascript:;";

m_hplEndDate.NavigateUrl ="javascript:;";

this.m_editStartDate.Text ="01/01/2005";

this.m_editEndDate.Text ="12/31/2005";

//

// Now disable all of the controls except for the job type selector

//

EnableControls(false);

ShowControls(false);

}

}

}

privatestring Quartz_QueryString(string strName)

{

string strReturn ="";

if (Request.QueryString[strName] !=null && Request.QueryString[strName].Length > 0)

{

strReturn = Request.QueryString[strName].ToString();

}

return (strReturn);

}



The problem is that when the new page is redisplayed, all the values are set correctly, but when I attempt to resubmit the page, the line
if (Quartz_QueryString("redo") =="1")

resolves to true even though I'm doing a post via my submit button. Consequently any changes I make to the variables don't stick when the form is ultimately submitted. Any thoughts??
Regards,
Greg.

Possible solution:
I changed the QueryString check to the following:

if (Context.Items["RedoQuery"] !=null && Context.Items["RedoQuery"].ToString().Length > 0)
{
// Reload form from session values
}

This has the desired effect. After the initial Page_Load() the context disappears and the above code block is not called repeatedly.

Strange behavior

Hello guys,
I have a strange behaviour in my asp.net web page. My page
contains a datagrid control, which has another nested
datagrid as a user control. It works very well, when the
user expands the + button or closes it with the same
buton. However when I do this several times successively
then suddenly I got the error message:
Object reference not set to an instance of an object.
objGetDailyStoreQuantitySold.StartDate = CType(e.Item.Cells
(0).FindControl("lblInvoiceDate"), Label).Text
When I do a refresh then it sees the label control again.
I am somehow why this is happening. Can somebody
help?
ThanksBy looking at this code, all one could really say is that:
objGetDailyStoreQuantitySold could be Nothing.
e could be Nothing.
e.Item could be Nothing
e.Item.Cells could be Nothing
...
etc.
You'll need to show a little more code or step through with a debugger
to get more details. Know what I mean?
Scott
http://www.OdeToCode.com/blogs/scott/
On Thu, 10 Feb 2005 08:01:10 -0800, "anonymous"
<anonymous@.discussions.microsoft.com> wrote:

>Hello guys,
>I have a strange behaviour in my asp.net web page. My page
>contains a datagrid control, which has another nested
>datagrid as a user control. It works very well, when the
>user expands the + button or closes it with the same
>buton. However when I do this several times successively
>then suddenly I got the error message:
>Object reference not set to an instance of an object.
>objGetDailyStoreQuantitySold.StartDate = CType(e.Item.Cells
>(0).FindControl("lblInvoiceDate"), Label).Text
>
>When I do a refresh then it sees the label control again.
>I am somehow why this is happening. Can somebody
>help?
>Thanks

Strange behavior

Hello guys,

I have a strange behaviour in my asp.net web page. My page
contains a datagrid control, which has another nested
datagrid as a user control. It works very well, when the
user expands the + button or closes it with the same
buton. However when I do this several times successively
then suddenly I got the error message:

Object reference not set to an instance of an object.
objGetDailyStoreQuantitySold.StartDate = CType(e.Item.Cells
(0).FindControl("lblInvoiceDate"), Label).Text

When I do a refresh then it sees the label control again.
I am somehow confused why this is happening. Can somebody
help?

ThanksBy looking at this code, all one could really say is that:

objGetDailyStoreQuantitySold could be Nothing.
e could be Nothing.
e.Item could be Nothing
e.Item.Cells could be Nothing
...
etc.

You'll need to show a little more code or step through with a debugger
to get more details. Know what I mean?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 10 Feb 2005 08:01:10 -0800, "anonymous"
<anonymous@.discussions.microsoft.com> wrote:

>Hello guys,
>I have a strange behaviour in my asp.net web page. My page
>contains a datagrid control, which has another nested
>datagrid as a user control. It works very well, when the
>user expands the + button or closes it with the same
>buton. However when I do this several times successively
>then suddenly I got the error message:
>Object reference not set to an instance of an object.
>objGetDailyStoreQuantitySold.StartDate = CType(e.Item.Cells
>(0).FindControl("lblInvoiceDate"), Label).Text
>
>When I do a refresh then it sees the label control again.
>I am somehow confused why this is happening. Can somebody
>help?
>Thanks

Strange Behavior ASPnet_Wp.exe

Hi all,
i have opened my application and did some work, i could see
i the task manager the Mem usage is 76,476K, I closed my application
and made sure that no instance of .net is running, but when i saw that
task manager after closing all the application , in the task manager it
still shows 76,476K, Would somebody please explain me why the memory is
not released.
Thanks in Advance
Regards
thomsonOn 25 Nov 2005 21:09:38 -0800, thomson wrote:

> Hi all,
> i have opened my application and did some work, i could see
> i the task manager the Mem usage is 76,476K, I closed my application
> and made sure that no instance of .net is running, but when i saw that
> task manager after closing all the application , in the task manager it
> still shows 76,476K, Would somebody please explain me why the memory is
> not released.
It's not strange at all. You merely have a misunderstanding of the way web
applications work.
HTTP is a stateless protocol. What this means is that there is no way for
the app to "know" if you have closed your browser or not. All it can know
is if you haven't interacted with it in a given amount of time. This
amount of time is configurable in the application pool (under IIS6) or in
other ways under earlier versions.

Strange behavior by the codebehind

Hello, all. I created a few Label objects, and deleted some. However, later
when I was using the codebehind page in VS .NET 2003 to set the Text of the
existing labels, I noticed that when I hit the period at the end of this"
"Me." I got the labels that had been deleted from the form's HTML. I
accidentally selected an item that was no longer on the form, and it took me
a few hours to debug that error "Object reference not set to an instance of
an object." I ultimately had to shut VS .Net down and restart it before I
even saw the new labels I had added. Hitting Refresh at the top of the
Solution Explorer didn't help.
Is this a known issue? Why am I still seeing the deleted Label objects when
I hit "Me."? Anyway to clear those items out permanently? I usually test my
pages without doing Rebuild, but by hitting F5. Could that have something to
do with it? Thanks.I think I've seen what you are talking about. Any time I add control in
HTML, I ALWAYS swith to the Design tab. This seems to synchronize the
codebehind (it doesn't always remove old controls though). Of course, some
people avoid the Design tab like the plague, in which case you need to add
your code-behind declarations manually.
In your codebehind, if you expand the #Region " Web Form Designer Generated
Code " section. You'll see all the current (and probably past) control
declarations you had on your form. It is safe to delete any orphaned ones.
Greg
"dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> Hello, all. I created a few Label objects, and deleted some. However,
> later
> when I was using the codebehind page in VS .NET 2003 to set the Text of
> the
> existing labels, I noticed that when I hit the period at the end of this"
> "Me." I got the labels that had been deleted from the form's HTML. I
> accidentally selected an item that was no longer on the form, and it took
> me
> a few hours to debug that error "Object reference not set to an instance
> of
> an object." I ultimately had to shut VS .Net down and restart it before I
> even saw the new labels I had added. Hitting Refresh at the top of the
> Solution Explorer didn't help.
> Is this a known issue? Why am I still seeing the deleted Label objects
> when
> I hit "Me."? Anyway to clear those items out permanently? I usually test
> my
> pages without doing Rebuild, but by hitting F5. Could that have something
> to
> do with it? Thanks.
>
I wouldn't call it a bug, just a limitation of what VS.Net can safely do.
In your codebehind, you'll notice a region named #Region " Web Form Designer
Generated Code ", if you expand this, you'll see all those labels you
deleted in the aspx file still declared. That's what Me. uses to show that
list...you can safely delete them.
When VS.Net adds those controls to that region, it does so 'cuz it found
them on your page, but when you remove them, vs.net can't safely remove
them..just because it isn't on the page doesn't mean you aren't dynamically
creating them in codebehind.
The new code-besides model of ASP.Net 2.0 makes these declaration dissapear,
along with the problem.
Karl
MY ASP.Net tutorials
http://www.openmymind.net/
"dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> Hello, all. I created a few Label objects, and deleted some. However,
later
> when I was using the codebehind page in VS .NET 2003 to set the Text of
the
> existing labels, I noticed that when I hit the period at the end of this"
> "Me." I got the labels that had been deleted from the form's HTML. I
> accidentally selected an item that was no longer on the form, and it took
me
> a few hours to debug that error "Object reference not set to an instance
of
> an object." I ultimately had to shut VS .Net down and restart it before I
> even saw the new labels I had added. Hitting Refresh at the top of the
> Solution Explorer didn't help.
> Is this a known issue? Why am I still seeing the deleted Label objects
when
> I hit "Me."? Anyway to clear those items out permanently? I usually test
my
> pages without doing Rebuild, but by hitting F5. Could that have something
to
> do with it? Thanks.
>
On Mon, 6 Sep 2004 12:23:20 -0400, dw <cougarmana_NOSPAM@.uncw.edu> wrote:

> Hello, all. I created a few Label objects, and deleted some. However,
> later
> when I was using the codebehind page in VS .NET 2003 to set the Text of
> the
> existing labels, I noticed that when I hit the period at the end of this"
> "Me." I got the labels that had been deleted from the form's HTML. I
> accidentally selected an item that was no longer on the form, and it
> took me
> a few hours to debug that error "Object reference not set to an instance
> of
> an object." I ultimately had to shut VS .Net down and restart it before I
> even saw the new labels I had added. Hitting Refresh at the top of the
> Solution Explorer didn't help.
> Is this a known issue? Why am I still seeing the deleted Label objects
> when
> I hit "Me."? Anyway to clear those items out permanently? I usually test
> my
> pages without doing Rebuild, but by hitting F5. Could that have
> something to
> do with it? Thanks.
>
VS.NET does not delete those old references very well (the variable
declarations at the top of the code-behind class, sometimes they're hidden
in the auto-generated section, that's why you see them). I know for a
fact if you're going to rename a control on the aspx, do it in the Design
View, in the Properties window for that control. Otherwise the name does
not get updated on the codebehind (especially if you do it in the HTML
view).
As far as deleting, I'm not sure, but it's pry just as quirky. Try
deleting it on the Design view, not in the HTML view of the aspx. Then I
usually always switch to Design view after updating my .aspx and
double-click on the document to have VS.NET switch over to the code-behind
automatically. Seems it's then able to do things a little more cleanly,
though things you delete may still not get cleaned up as well.
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
"dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> I got the labels that had been deleted from the form's HTML.
1. Make sure that you always mess around with the IDE tab, not the HTML tab.
2. Also, leave the auto generated code Region alone, do not add/modify this
region because IDE thinks that it no longer owns it and will not clean it
properly for you. I tried to trick it by adding couple of blanks and I can
repeat the problem.
3. Keep in mind that it will never get grid of "user's event/behavior" for
you, which is good, you will have to clean it yourself if you decide not to
keep the code.
John
Thank you, Greg, Craig, Karl, and WJ. All make perfect sense. Yes, I was
editing the code in HTML, and so VS couldn't know of the items I'd added or
deleted. For awhile there, I thought I'd broken VS. Thanks for your help :)
"WJ" <JohnWebbs@.HotMail.Com> wrote in message
news:uXLn7NDlEHA.3496@.TK2MSFTNGP12.phx.gbl...
> "dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
> news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> 1. Make sure that you always mess around with the IDE tab, not the HTML
tab.
> 2. Also, leave the auto generated code Region alone, do not add/modify
this
> region because IDE thinks that it no longer owns it and will not clean it
> properly for you. I tried to trick it by adding couple of blanks and I can
> repeat the problem.
> 3. Keep in mind that it will never get grid of "user's event/behavior" for
> you, which is good, you will have to clean it yourself if you decide not
to
> keep the code.
> John
>
On Mon, 6 Sep 2004 12:43:31 -0400, Karl <karl REMOVE @. REMOVE openmymind
REMOVEMETOO . ANDME net> wrote:

> When VS.Net adds those controls to that region, it does so 'cuz it found
> them on your page, but when you remove them, vs.net can't safely remove
> them..just because it isn't on the page doesn't mean you aren't
> dynamically
> creating them in codebehind.
>
I always wondered if that was what they were really doing, but I still
considered it annoying...
Unfortunately being an OO purist, I'm not too high on the partial type
approach of 2.0 either, oh well :) I still have my business layer...
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Particularly annoying is that I cannot set the base class for my page
in code, I have to modify the Inherits attribute VS.NET sticks in the
@. Page directive...
Scott
http://www.OdeToCode.com
On Mon, 06 Sep 2004 12:18:21 -0500, "Craig Deelsnyder"
<cdeelsny@.no_spam_4_meyahoo.com> wrote:

>On Mon, 6 Sep 2004 12:43:31 -0400, Karl <karl REMOVE @. REMOVE openmymind
>REMOVEMETOO . ANDME net> wrote:
>
>I always wondered if that was what they were really doing, but I still
>considered it annoying...
>Unfortunately being an OO purist, I'm not too high on the partial type
>approach of 2.0 either, oh well :) I still have my business layer...

Strange behavior by the codebehind

Hello, all. I created a few Label objects, and deleted some. However, later
when I was using the codebehind page in VS .NET 2003 to set the Text of the
existing labels, I noticed that when I hit the period at the end of this"
"Me." I got the labels that had been deleted from the form's HTML. I
accidentally selected an item that was no longer on the form, and it took me
a few hours to debug that error "Object reference not set to an instance of
an object." I ultimately had to shut VS .Net down and restart it before I
even saw the new labels I had added. Hitting Refresh at the top of the
Solution Explorer didn't help.

Is this a known issue? Why am I still seeing the deleted Label objects when
I hit "Me."? Anyway to clear those items out permanently? I usually test my
pages without doing Rebuild, but by hitting F5. Could that have something to
do with it? Thanks.I think I've seen what you are talking about. Any time I add control in
HTML, I ALWAYS swith to the Design tab. This seems to synchronize the
codebehind (it doesn't always remove old controls though). Of course, some
people avoid the Design tab like the plague, in which case you need to add
your code-behind declarations manually.

In your codebehind, if you expand the #Region " Web Form Designer Generated
Code " section. You'll see all the current (and probably past) control
declarations you had on your form. It is safe to delete any orphaned ones.
Greg

"dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> Hello, all. I created a few Label objects, and deleted some. However,
> later
> when I was using the codebehind page in VS .NET 2003 to set the Text of
> the
> existing labels, I noticed that when I hit the period at the end of this"
> "Me." I got the labels that had been deleted from the form's HTML. I
> accidentally selected an item that was no longer on the form, and it took
> me
> a few hours to debug that error "Object reference not set to an instance
> of
> an object." I ultimately had to shut VS .Net down and restart it before I
> even saw the new labels I had added. Hitting Refresh at the top of the
> Solution Explorer didn't help.
> Is this a known issue? Why am I still seeing the deleted Label objects
> when
> I hit "Me."? Anyway to clear those items out permanently? I usually test
> my
> pages without doing Rebuild, but by hitting F5. Could that have something
> to
> do with it? Thanks.
I wouldn't call it a bug, just a limitation of what VS.Net can safely do.
In your codebehind, you'll notice a region named #Region " Web Form Designer
Generated Code ", if you expand this, you'll see all those labels you
deleted in the aspx file still declared. That's what Me. uses to show that
list...you can safely delete them.

When VS.Net adds those controls to that region, it does so 'cuz it found
them on your page, but when you remove them, vs.net can't safely remove
them..just because it isn't on the page doesn't mean you aren't dynamically
creating them in codebehind.

The new code-besides model of ASP.Net 2.0 makes these declaration dissapear,
along with the problem.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/

"dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> Hello, all. I created a few Label objects, and deleted some. However,
later
> when I was using the codebehind page in VS .NET 2003 to set the Text of
the
> existing labels, I noticed that when I hit the period at the end of this"
> "Me." I got the labels that had been deleted from the form's HTML. I
> accidentally selected an item that was no longer on the form, and it took
me
> a few hours to debug that error "Object reference not set to an instance
of
> an object." I ultimately had to shut VS .Net down and restart it before I
> even saw the new labels I had added. Hitting Refresh at the top of the
> Solution Explorer didn't help.
> Is this a known issue? Why am I still seeing the deleted Label objects
when
> I hit "Me."? Anyway to clear those items out permanently? I usually test
my
> pages without doing Rebuild, but by hitting F5. Could that have something
to
> do with it? Thanks.
On Mon, 6 Sep 2004 12:23:20 -0400, dw <cougarmana_NOSPAM@.uncw.edu> wrote:

> Hello, all. I created a few Label objects, and deleted some. However,
> later
> when I was using the codebehind page in VS .NET 2003 to set the Text of
> the
> existing labels, I noticed that when I hit the period at the end of this"
> "Me." I got the labels that had been deleted from the form's HTML. I
> accidentally selected an item that was no longer on the form, and it
> took me
> a few hours to debug that error "Object reference not set to an instance
> of
> an object." I ultimately had to shut VS .Net down and restart it before I
> even saw the new labels I had added. Hitting Refresh at the top of the
> Solution Explorer didn't help.
> Is this a known issue? Why am I still seeing the deleted Label objects
> when
> I hit "Me."? Anyway to clear those items out permanently? I usually test
> my
> pages without doing Rebuild, but by hitting F5. Could that have
> something to
> do with it? Thanks.

VS.NET does not delete those old references very well (the variable
declarations at the top of the code-behind class, sometimes they're hidden
in the auto-generated section, that's why you see them). I know for a
fact if you're going to rename a control on the aspx, do it in the Design
View, in the Properties window for that control. Otherwise the name does
not get updated on the codebehind (especially if you do it in the HTML
view).

As far as deleting, I'm not sure, but it's pry just as quirky. Try
deleting it on the Design view, not in the HTML view of the aspx. Then I
usually always switch to Design view after updating my .aspx and
double-click on the document to have VS.NET switch over to the code-behind
automatically. Seems it's then able to do things a little more cleanly,
though things you delete may still not get cleaned up as well.

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
"dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> I got the labels that had been deleted from the form's HTML.

1. Make sure that you always mess around with the IDE tab, not the HTML tab.

2. Also, leave the auto generated code Region alone, do not add/modify this
region because IDE thinks that it no longer owns it and will not clean it
properly for you. I tried to trick it by adding couple of blanks and I can
repeat the problem.

3. Keep in mind that it will never get grid of "user's event/behavior" for
you, which is good, you will have to clean it yourself if you decide not to
keep the code.

John
Thank you, Greg, Craig, Karl, and WJ. All make perfect sense. Yes, I was
editing the code in HTML, and so VS couldn't know of the items I'd added or
deleted. For awhile there, I thought I'd broken VS. Thanks for your help :)

"WJ" <JohnWebbs@.HotMail.Com> wrote in message
news:uXLn7NDlEHA.3496@.TK2MSFTNGP12.phx.gbl...
> "dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
> news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> > I got the labels that had been deleted from the form's HTML.
> 1. Make sure that you always mess around with the IDE tab, not the HTML
tab.
> 2. Also, leave the auto generated code Region alone, do not add/modify
this
> region because IDE thinks that it no longer owns it and will not clean it
> properly for you. I tried to trick it by adding couple of blanks and I can
> repeat the problem.
> 3. Keep in mind that it will never get grid of "user's event/behavior" for
> you, which is good, you will have to clean it yourself if you decide not
to
> keep the code.
> John
On Mon, 6 Sep 2004 12:43:31 -0400, Karl <karl REMOVE @. REMOVE openmymind
REMOVEMETOO . ANDME net> wrote:

> When VS.Net adds those controls to that region, it does so 'cuz it found
> them on your page, but when you remove them, vs.net can't safely remove
> them..just because it isn't on the page doesn't mean you aren't
> dynamically
> creating them in codebehind.
I always wondered if that was what they were really doing, but I still
considered it annoying...

Unfortunately being an OO purist, I'm not too high on the partial type
approach of 2.0 either, oh well :) I still have my business layer...

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Particularly annoying is that I cannot set the base class for my page
in code, I have to modify the Inherits attribute VS.NET sticks in the
@. Page directive...

--
Scott
http://www.OdeToCode.com

On Mon, 06 Sep 2004 12:18:21 -0500, "Craig Deelsnyder"
<cdeelsny@.no_spam_4_meyahoo.com> wrote:

>On Mon, 6 Sep 2004 12:43:31 -0400, Karl <karl REMOVE @. REMOVE openmymind
>REMOVEMETOO . ANDME net> wrote:
>>
>> When VS.Net adds those controls to that region, it does so 'cuz it found
>> them on your page, but when you remove them, vs.net can't safely remove
>> them..just because it isn't on the page doesn't mean you aren't
>> dynamically
>> creating them in codebehind.
>>
>I always wondered if that was what they were really doing, but I still
>considered it annoying...
>Unfortunately being an OO purist, I'm not too high on the partial type
>approach of 2.0 either, oh well :) I still have my business layer...

Strange Behavior for Pages Named Default.aspx

I have several asp.net 2.0 apps written in VS2005 in C#. For each one,
I like to create and track page view events, increment counters, etc.
I do this in a block on each page, like this...
protected void Page_Load(object sender, EventArgs e)
{
if(!this.Page.IsPostBack)
{
Event.Write(EventSource.UserActivity,EventType.Informational,"My
event text");
Counter.Hit(WebPage.MyPage);
}
}
Now, for the problem. I noticed that many events are being written
twice, and many counters are being incremented twice when viewing the
page only once. When I set a breakpoint inside the code block above,
for any page named "Default.aspx" (no matter where it is in the folder
structure) the lines inside the code block execute twice. If I rename
the page to something else, they execute only once, as expected.
Does anyone know what causes this? How can I fix it?Hi Joey,
Seems page events are fired twice because event handler is assigned two
times - by the AutoWireupEvent directive and by your code by adding the
handler explicitely (vb.net AddHandler or Handles clauses)
Milosz
"Joey" wrote:

> I have several asp.net 2.0 apps written in VS2005 in C#. For each one,
> I like to create and track page view events, increment counters, etc.
> I do this in a block on each page, like this...
> protected void Page_Load(object sender, EventArgs e)
> {
> if(!this.Page.IsPostBack)
> {
> Event.Write(EventSource.UserActivity,EventType.Informational,"My
> event text");
> Counter.Hit(WebPage.MyPage);
> }
> }
> Now, for the problem. I noticed that many events are being written
> twice, and many counters are being incremented twice when viewing the
> page only once. When I set a breakpoint inside the code block above,
> for any page named "Default.aspx" (no matter where it is in the folder
> structure) the lines inside the code block execute twice. If I rename
> the page to something else, they execute only once, as expected.
> Does anyone know what causes this? How can I fix it?
>
On Jun 27, 5:38 pm, Milosz Skalecki [MCAD] <mily...@.DONTLIKESPAMwp.pl>
wrote:
> Hi Joey,
> Seems page events are fired twice because event handler is assigned two
> times - by the AutoWireupEvent directive and by your code by adding the
> handler explicitely (vb.net AddHandler or Handles clauses)
> --
> Milosz
>
> "Joey" wrote:
>
>
>
> - Show quoted text -
My code does not explicitly assign any event handlers.
Hi again Joey,
I hope you are well. Could you please paste both aspx page and code beside
so we could have a look?
--
Milosz
"Joey" wrote:

> On Jun 27, 5:38 pm, Milosz Skalecki [MCAD] <mily...@.DONTLIKESPAMwp.pl>
> wrote:
> My code does not explicitly assign any event handlers.
>