Solved

How to deal with 'Page_PreRender(object sender, EventArgs e)'  when iterations (loops) are involved.  Getting double the transactions

Posted on 2008-10-23
4
667 Views
Last Modified: 2013-12-17
Greetings:

I have a web page that generates help desk tickets.  Certain request should generate four tickets for the user's one request  -  so that four different departments of the company can take action.

With my current setup things worked fine when there wasn't a FOR LOOP involved that iterates four times:

 for (i = 0; i < 4; i = i + 1)

Is it possible the Page_PreRender() causes duplicates?  I don't get this problem when a step through the debugger but it does surface after I put the code on the production server.

Any ideas?

Thanks!
0
Comment
Question by:John500
  • 2
4 Comments
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22795758
firstly, you dont need to do
i=i+1 in your loop. just do i++ though that shuoldnt make much difference.

Post more code please so we can have a look.

Fyi : Page_Prerender fires only once.
0
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 250 total points
ID: 22806180
as per msdn the prerender will be called for every control
http://msdn.microsoft.com/en-us/library/ms178472.aspx

i will recommend you to move your logic to the page_load event
that will be the best place as the load is called only once and you can take actions there safely
0
 
LVL 6

Assisted Solution

by:AmarIs26
AmarIs26 earned 250 total points
ID: 22806594
Every event in the lifecycle is called only once. Page_Prerender event gets called first then it calls the pre_render event of every control. If your logic is in prerender event of the page then its fine but like i said the issue might lie somewhere else. Forexample, if your page just finished creating tickets due to a postback and the user presses the refresh button of the browser or hits F5 then it will do another postback which can result in same processing to occur resulting in 4 more tickets.
 
0
 

Author Closing Comment

by:John500
ID: 31509419
Thanks.  Although this was not the actual problem, the information you both provided helps in other areas.  The problem boiled down to having this method in the loop:  

public void Confirmation(bool good, string text, string url);

It needed to be outside of it.  Thanks again.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now