1

basically what I am trying to achieve is this (asp.net 4) :

  • If a user does a postback on an ImageButton or similar control it should cause a page Post, and go through the entire asp life cycle.
  • If this has just happened, and the user presses F5 or similar to refresh, it should ignore all events from the previous post and just do a regular Get.
  • If the user clicks Save multiple times it should register only 1 Post and not cause duplicates being created etc.
  • If there are update panels on the page, a Post should only update the panels data, whereas a Get(refresh) should reload the entire page.

I have had a look around and am currently using the Response.Redirect method (once processing is completed in a post it does a response redirect to the same page to replace the Post with a Get). This is unsatisfactory for a number of reasons

  • It causes unnecessary overhead doing two page Posts every save
  • I would like to have regions of the page in Update Panels, and at the moment if you change something and save it in one region, it reloads the entire page.

I found this similar SO question here which highlights a few methods, none of which looks like they will solve my needs. I also found this which is an interesting method, but I was wondering if anyone could tell me if it will solve all my above needs before I try implement it? Also, is the onsubmit event firing the only difference between a Post or a refresh mimicking a Post?

Regarding the 3rd bullet above, I have read about the jQuery .one() function, but I am looking for an application wide solution, as most of the app has been developed without this in mind.

Thanks in advance!

Community
  • 1
  • 1
logan
  • 430
  • 5
  • 11
  • Regarding 3rd bullet, why would you want a more wider solution then using jQuery api with .one()? It works just fine and it isnt "ugly code" or any kind of workaround. – WeeklyDad Mar 20 '13 at 11:41
  • I am definitely not opposed to a jQuery solution, how would you suggest applying it application wide? I could tack on a class to all controls which post back, but we have regions where we postback from javascript on html controls. I was hoping for a server side solution as it would bottleneck all postbacks and allow a more holistic solution – logan Mar 20 '13 at 11:58
  • What you really should think of first is "Am I using my time effectively". What I mean right now, is that you're probably overthinking this whole. I cannot answers on the other bullets you asked for since my time is very limited, but on the third bullet, I'd say just go for .One(). `Example: $(".save").one("click, function() { your logic execute ONE time(); });` You also need to have in this one click some verification (dont now what you're saving but lets say a user) to see if user.Exists(). – WeeklyDad Mar 20 '13 at 12:11
  • Also I'd recommend you to read up on Ajax since jquery and Ajax goes good hand in hand. – WeeklyDad Mar 20 '13 at 12:32
  • "but I am looking for an application wide solution, as most of the app has been developed without this in mind" from my original question. It is a large app, and there is no fricken way I can go add a custom function for every postback button in the app! The nature of the code on the server is that it expects to run ONCE, so if there was a way to identify if a Post is exactly the same as one that has recently come in, besides time stamp, ignore it. – logan Mar 20 '13 at 13:15
  • You dont have to generlise a one click to just a button instead so it happens for every click within that range. – WeeklyDad Mar 20 '13 at 15:19

0 Answers0