in ajaxified page back button is not working - asp.net

in my ajaxified page i have used several user control shifting from one user control to anothe r and then pressing the back button takes me to first page instead of previously filtered page
how to solve this
all this filters are linkbuttons i am also using listview these filters are actually filtering the content of this listview

You may take a look at the jquery history plugin. If you are using UpdatePanel to perform the AJAX requests you might find this article helpful as well as this video.

Related

Page postback webpage flickers

I have 15 dropdowns on the page, and they are cascading dropdowns.
second dropdown loads data depending on the first one.
Whenever i change the dropdown item. It is posted back, and page flickers
can i remove it
so that my page stays still when the next dropdown loads
You want to do one of two things: either avoid the postback altogether, or set it up so that the whole page doesn't refresh. There are a few approaches I can think of to fix this problem:
1) Take a look at the CascadingDropDown control in the asp.net AJAX toolkit
2) Look into using the UpdatePanel control to cause the part of the page with cascading content to post back asynchronously
3) If the content of the cascading dropdowns is static, you may want to implement the dropdowns in a client-side script; either using native JavaScript events or a JavaScript framework like jQuery. example

.net page design with complicated Ajax relationship

I am creating a .net website in c#.
The master page contains a fixed footer bar from which you can display 'bookmarks'. I also have a remove function for each bookmark.
Some aspx pages may have a add bookmark/remove bookmark function (a button control) on them.
I use update panels throughout so button controls are always encapsulated by one.
If I add/remove a bookmark from an aspx page, I can trigger an update to the fixed footer panel. A delegate event is triggered in the aspx page which calls a method on the master page to update the fixed footer panel, so everything is sync'd dynamically.
It doesn't seem possible to do the same the other way around. If i remove a bookmark from the fixed footer, I would need to know if the current aspx page was displaying a bookmark control. Pretty much impossible I would have thought, but I'm open to suggestions.
With that in mind the question really is does anyone have a technique that they use to deal with these scenarios, such as calling a full page update or something similar, or is it a case of doing nothing until the next page load/postback?
Thanks in advance.

ListView Problem

I am using a ListView for displaying list of items in a List page. I am also using DataPager control in my page for paging.
PROBLEM
While I am in the middle of the List let 5th page out of 10 pages and going to another page then clicking browser back button I am again comming back to my list page with page number showing 1st page out of 10.
What could be the solution.
Thanks in advance.
ASP.NET uses PostBacks to manipulate the state of the form, such as paging. What this means is that every interaction on the page - a button click, a LinkButton click - is really just submitting (posting) a form back to the same page. Hence the name, postback. An unfortunate downside of this approach is that it breaks the back button.
One possible fix is to use the Post/Redirect pattern which is becoming more common with ASP.NET MVC, but the principles still apply. However, I'd strongly discourage using widely in your application, as it would essentially double the amount of requests.

Dynamic Controls, Update Panels and Events - Best Way To Achieve My Result

Been pulling my hair out and doing a bit of looking on the web to try and figure out an elegant solution to my issue.
I have a ProductImages.aspx page. It shows all of the images associated with that product in a dynamically created list. Events are wired up to each picture to allow you to update it.
This works fine.
However, I have an option at the end which lets me add a new image. This is a button which fires off a call to the AddImage method.
Now what is happening is that the original controls are being create and added to the page with events. Then the button event if fired which recreates all of the existing image controls and a new one. Add this point the new image control create after the OnInit does not have events attached due to the events being added AFTER the OnInit.
I can do a Response.Redirect to reload the page and fire the OnInit to wire up the events again but this seems very inelegant and destroys the point of using update Panels.
Any ideas?
I'm thinking you could always load the picture upload control in a div and have a Javascript link to toggle the display attribute of the div.
Or perhaps use CollapsiblePanels from the AjaxToolKit to hide and show the upload form.
I think either of those ways would be more elegant than doing a post back (even if it's in an UpdatePanel) just to retrieve the picture upload form.
Your questions makes it sound like you're saying that you can't put the controls in OnInit because it is only fired on the first load of the page. This is not the case - OnInit is fired each time the page is loaded (including postbacks), so you can re-create your controls there even when using an update panel.
One property that is different between the initial load and the postbacks is the Page.IsPostback property, which you can use to just perform actions on the first load of the page.

Passing data to server code from a client-side control using ASP.NET AJAX

I have a ListView on a page that displays a list of widgets. When a user clicks on one of the items in the list, I want to display a ModalPopup that contains controls allowing the user to operate on the item they selected.
I could easily accomplish this by placing a Panel and a ModalPopupExtender in the ListView's ItemTemplate, but this mean one set of hidden controls for each and every widget, which would massively bloat the page size. (There are going to be some rather heavyweight controls in there.) Instead I want to reuse a single ModalPopup for each of the widgets in the list.
I've done some searching but I haven't found anything that applies directly to my situation before. From what I've been able to figure out, however, I have to do something like this:
Place a Panel and a ModalPopupExtender on the page inside an UpdatePanel.
Build a custom WidgetManipulator user control that has a WidgetID property. Put this in the Panel, along with a couple OK/Cancel buttons.
In Javascript on the page, attach a click handler to each widget in the ListView that triggers a postback on the UpdatePanel.
On the UpdatePanel_Load event on the server, display the ModalPopup and then set the WidgetID propety on the WidgetManipulator to the ID of the clicked widget.
On the OKButton_Click event or CancelButton_Click event on the server, hide the ModalPopup. If OKButton was clicked, call WidgetManipulator.SaveChanges() first.
The part I haven't figured out is: How the heck do I know what widget was clicked on, and how do I pass that back to the server when I refresh the UpdatePanel? Is this even the right approach at all?
If you can use jQuery instead you could do something along the lines of these two posts:
Modal Delete Confirmation Version
Two Using jQuery SimpleModal Plugin
Demo
Inserting Content Using
jQuery SimpleModal Plugin Demo
When I need to pass data from client to server in ASP.NET AJAX, I generally use an asp:HiddenField with runat="server". Both can see it freely, but beware potential postback asynchronicity.
Sounds like you need to notify the server the widget was clicked - You may use a Timer to postback; or I'd go with option 5.

Resources