Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In a Panel I have FileUpload and on 'show' button click I am able to see the selected image by bringing down the scroll bar every time. How to arrest the vertical scroll bar from moving upwards. I tried with the following code but no use.


<script type="text/javascript">
var FormHandlerProto = function() {
var Me = this;

this.lastScrollPos = 0;

this.SetupForm = function() {
// Bind a function to the form's scroll container
$("#Panel117").bind("scroll", function() {
// Record the scroll position
Me.lastScrollPos = $(this).scrollTop();
});
}

this.ScrollForm = function() {
// Apply the last scroll position
$("#Panel117").scrollTop(Me.lastScrollPos);
}

this.EndRequestHandler = function(sender, args) {
if (args.get_error() != undefined)
Me.ScrollForm();
}
}
}

var FormHandler = new FormHandlerProto();
FormHandler.Setup(); // This assumes your scroll container doesn't get updated on postback. If it does, you'll want to call it in the EndRequestHandler.

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(FormHandler.EndRequestHandler);

</script>

XML
<asp:Panel ID="Panel117" runat="server"
    style="border-width: 1px; border-style: solid; top: 1475px; left: 125px; position: absolute; height: 161px; width: 279px; background-color:InactiveBorder; border-color:Black">
    <asp:Image ID="ImagePreview" runat="server" Height="97px" Width="99px"
            style="z-index: 1"/>
<asp:FileUpload ID="PhotoUpload" runat="server"
            style="z-index: 1; left:100px; top: 53px; position: absolute; height: 46px; width: 218px; right: 90px;" />
<asp:UpdatePanel ID="UpdatePanel5" runat="server"  >
<ContentTemplate>
<asp:Button ID="Button7" runat="server" CausesValidation="False"  onclick="Showbutton_Click"
            style="z-index: 1; left: 7px; top: 123px; position: absolute" Text="Show" />
</ContentTemplate>
 <Triggers  >
            <asp:PostBackTrigger ControlID="Button7"    />
            </Triggers>
 </asp:UpdatePanel>
</asp:Panel>
Posted
Comments
Sergey Alexandrovich Kryukov 15-Nov-14 3:10am    
Why do you think scrolling up is wrong? Does it move up against the user's will? :-)
—SA
S.Rajendran from Coimbatore 16-Nov-14 9:39am    
I never thought scrolling up is wrong,your highness.
Sergey Alexandrovich Kryukov 16-Nov-14 11:35am    
You did not understand my question; please read it again.
I think you need to explain what wrong behavior of scrolling makes your problem, exactly. So far, it's not quite clear.
—SA
S.Rajendran from Coimbatore 17-Nov-14 1:58am    
The behavior of the scroll bar moving upwards after show button clicked makes the user to pull down the scroll bar to view the selected image that resulted through 'Showbutton_Click' event in c#. So, if this scroll bar behavior of moving upwards is prevented, the user will be happy to see his selected image.
S.Rajendran from Coimbatore 20-Nov-14 9:51am    
???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900