|
Post by Admin on Aug 26, 2015 12:41:39 GMT
At the very first the requirement was to set position in same from where I pressed the button. So I set MaintainScrollPositionOnPostBack = true from c# or from page property.
After that I realized that, there is button I have to go to top after postback.
Now the problem is, I have to escape the MaintainScrollPositionOnPostBack only for that button.
What to do?
I searched a lot, tried a whole day with Javascript/JQuery and also from C#, but fails.
At last I did a little research on it. Actually the logic is the for MaintainScrollPositionOnPostBack to store the position in two JS variable, '__SCROLLPOSITIONX' and '__SCROLLPOSITIONY'.
Now I started to crack the code like that.
protected void BtnAddItems_Click(object sender, EventArgs e) { string script = @"<script language=javascript> var scrollX = document.getElementById('__SCROLLPOSITIONX'); var scrollY = document.getElementById('__SCROLLPOSITIONY'); if(scrollX != null && scrollY != null) { scrollX.value = 0; scrollY.value = 0; } </script> "; Page.ClientScript.RegisterStartupScript(Page.ClientScript.GetType(), Page.ClientID, script, false); }
And it succeed!!!!!
|
|
|
Post by Endre on Jan 25, 2018 18:13:52 GMT
Thank you!! Thank you!! Thank you!! Thank you!! I have been searching for days on how to override the page directive MaintainScrollPositionOnPostback. Thank you!! Thank you!! Thank you!! Thank you!!
|
|