I have recently been trying to figure out a problem on my C# ASP.Net webforms website and finally found the cause but no fix.
Explanation of the problem:
I have a gridview in an updatepanel. This gridview holds images uploaded by the user and also imagebuttons. The image buttons cause a partial postback. The postback carries out an action on a selected image and refreshed the gridview.
This works great until I tested in firefox. In Firefox after the partial postback, the page scrolls up to the top of the GRIDVIEW (not the webpage).
Cause of the problem:
The cause of the problem was because the div that contains the gridview has no set height value in the CSS. This cause the div to shrink back to zero when the Gridview is refreshed and in turn causing the current position of scroll to be non existent (well it is but not in the div) and thus bringing the page to the top of said div.
Fixes tried:
Tried setting the height of the DIV to 2000px which stopped the scroll but meant there was lots of excess space (not acceptable and this option can not be used as gridview size is dynamically changing)
Tried JS code to move the page back to position it was before the partial postback (Also worked but the scroll moved up and the JS moved it down. This looked very unprofessional)
Tried to setting the div to 2000px before a partial postback and then resizing it to fit it new elements in and end request... not successful.
Related
Have a label control in master page.Should get this control to content page's update panel.
The code in content page is
ModalPopupExtender popUp = (ModalPopupExtender)Master.FindControl("ModalPopupExtender1");
HtmlGenericControl lblMessage = (HtmlGenericControl)Master.FindControl("InfoMesg");
lblMessage.InnerText = "Invalid page number, Please enter valid page number.";
popUp.Show();
When update panel is place the message in lblMessage is not being displayed.
Can someone please help me achieve this.
First of all, why isn't it working? When postback is triggered by UpdatePanel (so to say), the only part of the page that will be updated on response is the UpdatePanel content. This label is outside of the UpdatePanel; therefore it won't be updated.
How to work around this anyway:
Obvious, but in theory most welcome solution. Move label inside the UpdatePanel, if it is something that logically belongs there. Of course this might not apply to your particular case.
UpdatePanel could register some script that would update the text of the label (make sure to use ClientID).
If your UpdatePanel does not have an UpdateMode set, or it is set to Always (basically this is a default value), afaik all other update panels will be updated as well when this one causes a postback. So you can wrap the label in a separate UpdatePanel.
I've got a number of RadGrids in various pages but on one of them, a particularly big one, now when the user changes the Page Size via the Pager text field it doesn't keep that: when the grid finishes updating it's reset the Page Size back to whatever it was. If I change the PagerStyle.Mode so there's a dropdown shown instead of a text field then they can change it just fine. I can change it back & forth between NextPrevNumericAndAdvanced and NextPrevAndNumeric, and consistently it works with a dropdown (NextPrevAndNumeric) but not with a text field (NextPrevNumericAndAdvanced). If I modify the Page Size with the pager shown as a dropdown, then change the aspx to use a text field, then it locks the Page Size at whatever I selected in the dropdown.
What could it be that is causing this?
Turns out the if (!Page.IsPostBack) ... had been removed from Page_Load, so on every postback it was resetting things. Putting this back resolved the problem.
this is my second question regarding more or less the same topic, since I am still struggling with it.
This is the layout I need to build:
Also important:
The header and the footer contain buttons, info but shouldn't be included in the page transitions (eg. shouldn't fade in or fade out).
In the end I just want the controls inside the "Page w/ content" (see picture below) area to be animated (fade in/fade out, etc) between the different pages.
What I got so far:
Header and Footer are user controls;
Page w/ content is a Lockablepivot (with headers hidden), and I use the pivot items to switch between the different content I want.
Problems:
I havent been able to put the Islocked = true working (it always gives me a null ref excep);
A pivot item is not really a page, so If the user for presses the back button it leaves the app (I think I can probably solve this by overriding the back button etc..);
I don't know if its easy or even doable to change the pivot items animations (haven't researched much about this one).
Ok, so my real question:
What other options do I have?
Using a ContentPresenter in the "Page w/ content" area to show me another xaml page? I read something about this being not good at all;
Do everything in one page but dynamically and through the code add, delete, fade in, fade out all the controls ?
Any ideas? What about performance? Which one should perform best?
Thank you!
Put an Header and Footer controls to a each page and make any animations with Content control you like
When setting the Page directive for MaintainScrollPositionOnPostBack to true on pages with CollapsiblePanelExtenders, the page does not properly maintain the scrolling position once a postback is made.
I've noticed that once the postback is made, the browser attempts to scroll to the original position before the collapsible panels are expanded again (as they are loaded in a collapsed state, and then expanded on the client side), and so the scrolling position either does not move at all or it makes it only part way.
One potential solution I can think of is to wrap the affected panels in an UpdatePanel to avoid the hard postback altogether, but this is not particularly ideal since this issue affects multiple screens.
You could capture the state of the CollapsiblePanelExtender into a HiddenField, then deal with the state of the CollapsiblePanelExtender serverside during the postback.
There are some examples here.
On a fairly complex page, we're getting some unusual behavior with dropdownlists in IE6. To layout the basic structure, there are 2 update panels on the page each with a GridView presenting a master-details layout. In addition to the grid, each panel houses some DropDownLists for filtering the data in the respective GridView.
Now what's happening is that a button on the bottom grid will cause a modal popup form to display, where some details about the row item can be modified. As per the ASP.NET AJAX JavaScript, the DropDowns disable during the postback, and re-enable after it closes.
The bottom grid also has a timer attached to it that periodically updates it to keep the view of the data fresh. When this timer ticks after the modal popup is closed, the drop down lists mysteriously vanish, except for the ones in that update panel which apparently get rendered again.
Oddly enough, if the timer ticks while the popup is up, the drop downs enable early and show through the modal (oh IE6...) but don't vanish later on.
Been a while since I posted this, but the problem occasionally resurfaces and I think I finally found an answer to it.
The AJAX Toolkit's modal popup javascript disables all DropDownLists on the page because they show through to the highest Z-level in IE6. But if something causes a postback while the modal is showing (like a badly managed timer) then the invisible state gets recorded into the viewstate for the DDLs.
One easy way around it is to just put the offending DDLs in an update panel, so they properly get refreshed on updates and don't get stuck. The more complex way is to ensure nothing causes extraneous postbacks while the modal is showing. The best way would probably be to ditch Webforms and all the baggage with it, but that's pretty much not going to happen.