Back with another web based issue.
When a control issues a postback to the server the page refreshes (Fine). The page also scrolls back to the top and loses the control that is selected. If it's relevent after the postback depending on what changes have happened controls are made visible or made hidden. The focus is lost and current scroll resets even if nothing is changed on the page visibility wise. The data inputted in Text fields is kept and so are any radiobutton/checkbox selections. The problem is tabbing is reset to index 0 and the pages scroll is sent back to the top of the page.
I am using .Net 4.0
I have tried adding MaintainScrollPositionOnPostback="true" both on the asp page itself and in the web.config to no avail.
I have tried with and without the Ajax updatepanel using conditional updating triggering off when textboxes text is changed or radiobuttons are changed and the postback still causes a scroll and index loss.
Any ides would be fantastic. Ta!
First of all, the MaintainScrollPositionOnPostback="true" has a known bug in asp.net 2.0, see here.
Also, the correct syntax is maintainScrollPositionOnPostback. (lowercase m)
I used the maintainScrollPositionOnPostback but have many problems in IE, then I use the asp.net AJAX Control Toolkit UpdatePanel, it solves the problem (the page don't scroll to the top) and save some bandwidth.
EDIT:
I think I understand your problem, it's mantain the focus on the element, it can be done using some javascripts workarounds, se here.
Hope that helps.
Related
Using a combination of asp.net, jQuery, and c# and stored procedures.
I have successfully created a gridview, which I then apply jQuery datatables plugin to provide text column filtering (I disabled most of the other datatables function/settings off)).
The Gridview works as expected and when I make use of the RowEditing and RowUpdating events also, IE the editable fields update nicely.
If the user clicks and edits, then clicks the update link, the database is updated and the page reloads. now if that person has scrolled down say record 50 (half way down for instance) in order to locate and then edit that record, then after the page refresh, the user then has to scroll back down to find that same record.
I'm trying to find a way of returning the user to the same location (record) that they had just edited before the page refresh after the page refresh.
I found a very simple solution to my problem with out a load of coding and it turned out to be MaintainScrollPositionOnPostback="True" page directive.
Unless I've misunderstood; your dilemma is nothing to do with gridviews etc, and is all to do with merely maintaining page scroll position on post-back... have a read of this JavaScript solution from the 4 guys
P.S. Google is your friend
I am working on .net 4.0 application. I am trying to load a bunch of custom controls that has a "gridview" control along with several text boxes and dropdowns. As the viewstate is really slowing down the system in order to improve the performance I Disabled the ViewStateMode of the parent control (i.e User control) and Enabled the ViewStateMode for dropdowns. But the problem I have is the dropdowns inside the gridview and panel thrw an error even though their ViewStateMode is Enabled. If I Enable the ViewStateMode of gridView or Panel it works fine but that's increasing the size of Viewstate.
Can somebody please make me understand why it is happening and what is the solution for this?
Thanks
BB
If you are getting tons of viewstate.Then I would suggest you two ways that worked for me too
Compress Viewstate - http://www.codeproject.com/KB/viewstate/ViewStateCompression.aspx, http://www.hanselman.com/blog/ZippingCompressingViewStateInASPNET.aspx
Trace the layout of the rendering area in html, using div , ul, li wahtever. Now instead of placing grids and other server controls, get the datasource(datatable or dataset), itereate through the items and make the html in the codebehind and write the final html tag on page using a literal. using html controls you can get rid of the view state issues. Also on that html tag you can apply jquery to make it better too.
I have an UpdatePanel that contains a repeater that basically builds a list of checkboxes. Those check boxes are set to AutoPostback with an "OnCheckedChanged" event.
When the user checks a checkbox, everything happens as expected except for one thing, the page pops (or scrolls) back to the top.
Other controls that cause this UpdatePanel to refresh don't cause this issue, even just plain checkboxes that ARE NOT inside of my repeater, but still within the UpdatePAnel, work fine (no scroll back to top)...
Any ideas?
open your page in designview (Source) at the top you will find pagedirectives
try adding MaintainScrollPositionOnPostback="true"
hope it helps !!!
i am using asp.net with c# web app in vs 2008
problem 1:
i do not know why Telerik RadControls- RadFormDecorator Moves some controls (such as Buttons or chech boxes) and changes their positioning up or down in my form after viewing in browser...
i put those controls in a cell of a table ... but not help
i had this problem about radajaxmanager and by setting UpdatePanelsRenderMode property to inline problem solved - but here there is no property like that...
what is going on here?
problem2:
i decorated my buttons and chechboxes with radformdecorator (telerik radcontrols) control...
when i click on a checkbox to set it to true or false so my webpage positioning goes to up (like when postback occurs , but this is not postback)
how can i prevent this problem ?
thanks for attention
This happens in some scenarios because of the way RadFormDecorator styles checkboxes - real checkboxes are hidden outside of the viewport. When the decorated checkbox is clicked however, browsers try to focus the real checkbox, hence the "jumping". To avoid that, you should set position:relative to the parent container.
I have a main page into which i load a user control with a grid and add/edit link buttons.
If I bind the grid by setting the datasource and calling the databind() method in the page load event then it sets properly. However, I want to keep the selected row between postbacks, so I wrap the bind code in "if (!Page.IsPostBack) {}" as usual. My problem is the page load always registers it as a postback and my code never runs.
I am using the 2.0 framework, and my grid is an 2008.1 Infragistics for the 2.0 framework.
I thinking this must be something simple.... or hoping anyway!
Thanks in advance
If you place your control into an UpdatePanel, then you should check for Page.IsCallback instead of Page.IsPostBack.
The two ways I found round this were:
to load the user controls when the page is first loaded and then hide them until user selected what they need to see.
to load a new page into an iframe on the main page allowing it to have its own page control meaning when its loaded in at first its not a postback.
Not the greatest, but gets by.
Thanks for the help.
I have mixed feelings about necroing a thread this old, but the question is still relevant, and there weren't any great solutions offered, so though I would add what I recently did to solve the same issue:
I had a similar problem with a site I was building. My solution was to add a method to the user control called "OnFirstLoad" that does all of the stuff I would have wrapped in an "if not Page.IsPostback" block. I then call the "OnFirstLoad" method from the hosting page the first time the control is loaded into the control tree. This way the control itself doesn't have to worry about whether or not this is a postback, and the main page can initialize it as needed.