?
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
Medium Priority
?
719 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 1000 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 1000 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

Industry Leaders: 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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

771 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