BeautyTips - Refresh after postback - c#

I'm using the BeautyTips jQuery plugin in a template column in my RadGrid to show additional information.
Everything is working well, but I have one issue: After the user applies some changes and clicks the update button (which causes a partial page update), the BeautyTips plugin still shows the outdated info.
I've put a breakpoint on the code that loads the info it uses, and it is not hit after initally loading them; so BeautyTips is caching that result somewhere.
Is anybody aware of a way I can force those to refresh?

OK; I figured this one out:
There's an option in BeautyTips called ajaxCache which will cache the results of ajax calls.
Setting this to false (the default is true) solved my problem.

Related

How to get drop down list to validate during postback?

Well, I found the problem I was facing with the post back earlier. Somehow it turns out that drop down list, is failing event validation in all the pages. It wasn't failing validation earlier, so no idea what happened.
Anyway, now I have some 400 pages where this thing is happening. So, adding some code in all of them is out of question. So, now I want to know what I can do to get the drop down list considered as valid during the postback? Adding update panel is out of question as I will have to do it on oh so many pages.
Edit:
More details:
I have an application created in .Net 1.1. I ran the upgrade wizard in VS to upgrade to VS2012. Since then, I am finding a lot of bugs when post back happens. I had two functions for handling click event for buttons. The javascript function (used for validation) is fired properly, but the asp function wasn't called at all.
So, last week, I set eventvalidation to false, and everything worked. After reading more about it, I realised that postback was failing validation check. I checked eventtarget attribute, but that was null. So, I kept looking further. After a lot of head scratching, I finally found the culprit of that postback failure.
In that application, we add items to the dropdown, based on database query results. So, it is modified on run time. The script modifying the control is added to "ClientScriptManager", but that doesn't work. So, right now, my code has some 400 forms with dozens of dropdownlist created in runtime.
I have to get these dropdownlist removed from postback validation, or somehow return true for the validation. And that's where lies the problem. I have no idea how to do this.
P.S. Do let me know, which piece of code I should add here, if needed.

asp.net dropdown displaying incorrectly in chrome

I have asp.net web forms page that has a asp.net dropdownlist control on it with an autopostback. When a user makes a selection in the drop down a get request is made to the same page with a query string parameter.
On postback I read the query string parameter and load / populate additional controls.
When a user presses the browsers back button the previous request is submitted (along with its query string). In the code behind I read the query string and load / populate additional controls, which works fine. I also try to select the appropriate item in the drop down (by value).
The issue I am seeing in the browser is that appropriate option text is not shown in the select. By inspecting the source I can see the the correct option has the selected="selected" attribute, so setting the selected item in the code behind was successful. But the text is incorrectly still the same as before the back button was pressed.
Curiously this only happens in chrome. ie and firefox both behave as expected.
Has anyone had any issues with asp.net drop down lists and chrome?
I'm stumped here.
I have created a simple example that demonstates this problem. src can be found at https://github.com/beembow/AspDotNetDropDownInChrome.git
Reproduce the error by selecting some values in drop down then pressing back button.
In which Page Event are you setting the selected value of the drop-down? It could be that you are setting it once the page is loaded, and that is why you don't see the dropdown set with the selected value.
They only fix I have found is similar to the one suggested ASP.NET - Google Chrome caching DropDownList selections.
I essentially add a global variable that holds the value of the option to select in the drop down. I do this via Page.RegisterStartupScript in the code behind.
I then have some js that looks for this global value, and if it finds it selects the appropriate option in the select via jquery.
This makes me think that the issue is something to do with how chrome treats some asp.net generated javascript / viewstate. It may also be something to do with chrome caching policies. curious that it works in both firefox and ie.
Either way, the solution described above is definitely an ugly hack. Would be interested in any solutions other people find.

Preventing duplicate postback processing when refreshing with update panels

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!

JavaScript generated web page issue

I have a problem with javascript generated web page. I have a web page on the internet that is generated by javascript. I am working on changing a web page using wpf web browser control. I have to make some changes to the web page by inserting jquery, and changing css and hiding some elements.
Here is the issue.
Application works ok most of the time, but sometimes, for reasons unknown, it does not change the css or hides the elements. I presume that it has something to do with the javascript that actually generates the page. My code is executed, but no changes are made, so I presume that the script cannot find the elements in the page because they do not exist in the page, at the time of the execution of my scripts. This is just an assumption.
I need help resolving this issue. I have tried delaying the execution of my scripts for n seconds, waiting for body.ready, document.ready and window.ready, but nothing helped. Also, I use wpf web browsers LoadCompleted event, but... From time to time, the script simply makes no effect on the page. Did somebody have this issue, does anyone have any idea how to solve it?
Thank you very much in advance...
When building single page apps, always use a framework like Backbone or Sammy.js together with Mustachejs (or Hogan.js) for templating.
Since we don't have any code to look at, if you're using jQuery, I suggest you check out .live() and .on() for attaching event handlers to elements you plan on loading into a div (making them clickable) etc.

Stop ASP.NET PostBacks Showing As Separate Pages?

I have an ASP.NET form that the user can make lots of changes to, each time they make a change the page PostsBack and the details are updated.
If the user hits the browser back button they go back through all the previous versions of the page.
Is it possible to stop each PostBack being treated by the browser as a new page?
So the would make any changes they like and if they hit the back button it brings them to the previous form and not the same form but a different version?
I know I could use AJAX to update values but I'm not an advanced coder so trying to keep things simple as I haven't used AJAX before.
Ajax is your only solution.
There is no way to remove a page from the browser history. Javascript is explicitly denied the capability.
Now, you could, potentially, stop them from using the back button at all. Although this might result in unhappy users and I'm not 100% certain it works in all browsers.
function body_onload(){
window.history.forward(1);
}
You could use a trick to do it.
On postback you can set a session bit to true saying they submitted that form. On your postback check to see if that value is set. If it is they are trying to do it again and you can just abort it. It wouldn't prevent the postback per se but you could control the logic and prevent it from DOING anything.
I personally would explore ajax as Jquery provides some nice ways to do it and it'd be a learning experience but I suppose this would work as you are asking. On a per session basis. If you only want 1 submission ever use a database to store the activity.
You could use UpdatePanel: http://msdn.microsoft.com/en-us/library/bb386454.aspx

Categories