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
714 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

687 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