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
Related
I have a curious issue. I have an ASP.NET web page that has a RadioButtonList with three RadioButtons. RadioButton1 hides both Panels. RadioButton2 displays Panel1 and hides Panel2 then RadioButton3 hides Panel1 and displays Panel2. Pretty straight forward. All of the logic that hide and display the Panels is in C# in the Code Behind. All of this works great in Chrome and IE. In Firefox; however, if you refresh the page in any way (another controls posts back or by hitting the browser's refresh button) while say RadioButton2 is selected and Panel1 is displayed the page comes back with the RadioButton2 still selected but both Panels are now hidden. In Chrome and IE a refresh of the page brings it back to it's original state. Meaning that all of the controls are set to their original values and RadioButton1 is selected and both Panels are hidden. Not necessarily ideal but a whole lot better than having the RadioButtons and Panels come back out of sync.
Not sure where to begin looking on this one. None of this is done in JavaScript. The panels and RadioButtons are not generated in code behind they are in the static HTML portion of the page.
Thoughts?
This sounds like you might be dealing with a page caching issue in Firefox. Have you tried disabling page caching for this page? For example, see this answer: Disable caching in Fire Fox in ASP.NET and C#
This is not really the answer I was hoping for because it seems incomprehensible to me that in 2014 we still have issues with browser inconsistencies but I put some code in the page to handle this and force it back into the proper state. This has solved the immediate problem.
I would like to embed a ListBox into an UpdatePanel. The ListBox needs to have multi select enabled, with a post back triggered on item selection. My problem is the scroll bar on postback. It gets back to the top everytime an item is clicked. I have tried different ways to back up the scroll position, there is just always something wrong with it (at least in IE8, the browser I have to focus on). Either I get a flicker, or as soon as the user uses his mouse wheel after post back, the scroll bar will then jump back to the top. This does not happen in Chrome and Mozilla.
I was thinking, maybe there is something that should work - posting back without ever redrawing my ListBox / udpating the containing UpdatePanel ? Is this possible ?
Any full postback will necessarily repaint a list view so maintaining the scroll position of the listview is going to be problematic
Smart Nav
If it is the position of the page scroll position you are struggling with then you could try smart navigation
http://msdn.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpositiononpostback.aspx
I don't think browser coverage is going to be hugely reliable for this (for example see http://forums.asp.net/p/1094179/1651390.aspx)
Update Panels and postback controls
If you are just updating the content in the update panel then it shouldn't lose it's page position. Make sure you are doing the partial post back and not the full. The listbox and the control triggering the postback should both be within the update panel.
There are caveats to this though - if you have a button outside of the update panel it can trigger the partial postback if it is in the triggers collection of the panel (http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.triggers.aspx)
JQuery AJAX
The nuclear option would be to use JQuery AJAX or similar e.g. proper AJAX not the strange fake halfway house stuff that the update panels use (not to say that they aren't very useful - just need to be used judiciously). JQuery AJAX is a swine to get working within the postback architecture so I wouldn't necessarily recommend.
Maintaining the ListBox scroll position
Note - if it is the listbox scroll position that you are concerned about them this question
Maintain scroll position in listboxes in updatepanels, NOT the page
gives some good advice
Hope that helps some
I think flickers could always happen whatever you do (flickering is actually the browser that renders contents in several phases).
You should start by trying the MaintainScrollPositionOnPostBack page's property.
http://msdn.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpositiononpostback.aspx
Why do you need to postback on every item selection ? Don't you mean an async postback ?
I had a similar issue with a ListBox inside a user control, and who in turn was in an UpdatePanel. I used jQuery to deal with click events on two buttons that were selecting and unselecting all items in the listbox.
Try this:
Create a .js file (e.g. select.js) and insert your jQuery code in there. Something like:
function pageLoad() {
//insert code here
}
Important to use pageLoad() instead of (document).ready.
Then, insert the script reference in your ScriptManager:
<asp:ScriptManager ID="sm" runat="server" EnablePartialRendering="True">
<Scripts>
<asp:ScriptReference Path="~/Scripts/Select.js" />
</Scripts>
</asp:ScriptManager>
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.
I have asp.net application and a TabContainer from AjaxControlToolkit on a form. There are 4 tabs, each containing UpdatePanel, hidden button and some custom .ascx (each with it's own javascript file). Buttons are triggers for panels to update the contents and they are triggered from the 'OnClientActiveTabChanged' event of the TabContainer.
This technique is described here and similiar here. It's pretty simple when looking at it.
The only problem I have is that the whole scenario works when used as a separate page but it doesn't seem to work when masterpage is around that page. Suddenly buttons act as full postback controls.
Do you have any idea what's the reason?
Assuming the buttons your referring to are on the master page, I think you'll want to register the master page buttons as update panel triggers.
http://www.asp.net/ajax/tutorials/understanding-asp-net-ajax-updatepanel-triggers
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.