The solution? Place a server control at the bottom of the page with CSS properties that prevent it from physically being viewed, don't affect scroll bars, and yet can still have focus shifted to it.
So begin by placing an ASP.NET button (or any other small server control) at the bottom of your markup, and add some inline styling to be most compact and streamlined if you wish:
Notice above the styling places it off the page, but the button will not create any lengthy scroll bars, etc. Lastly, add the code server side on the 'Finally' of the button click event to shift focus to the bottom of the page:
<!--Button will render, but not actually be visible to the client-->
<asp:Button ID="ui_btnPageBottom" runat="server" Text="Button" style="margin-left:-999px;" />
That's it! I am sure there are at least 20 ways to do this, including a purely client side solution with JavaScript, but this was 2 lines of code to accomplish what I needed.
Try
'Code
Finally
'Regardless of outcome, set focus to the bottom of the page
Page.SetFocus(Me.ui_btnPageBottom.ClientID)
End Try
0 comments:
Post a Comment