Issues encountered while developing the WebForm

Source: Internet
Author: User

When making a small project, a very long page with a contact us form at the bottom of the page

The entire page I did not use MVC, but using ASP. Net. WebForm (. aspx) to realize that when the user enters information at the bottom of the page and submits a submit form, the page automatically jumps to the top of the page (the scroll bar automatically goes up, Displayed to the user is the information at the top of the page)

In fact, after the user submit form, need to feedback a message to the user "Thank you for your information, we will contact you as soon as possible," in the original form position, let the user submit the form, you can see. That is, the page focus will stay there, not the page automatically jump to the top of the page

In the ASPX file, there is a property called MaintainScrollPositionOnPostBack that can be set, as follows

<%@ page language="C #" autoeventwireup="true" maintainscrollpositiononpostback="true"  codefile= " Default.aspx.cs "inherits="_default"  %>

This way, you can guarantee that the page will not automatically jump to the top of the page after postback, but stay where it is.

However, when I developed this, contact us form after the submission, the page at the bottom of the form hidden (visible=false), just in the original position of the form, put a label display feedback to the user of the successful submission of information

After that, the page will automatically jump to the top of the page after the submit form is found

Cause: Maintainscrollpositiononpostback= "true" needs to record the original location, when you submit the form, the record is the position of the form, now submit the submission, you hide the form, the program can not find a form, It will not be able to locate the original position, so it automatically jumps to the top.

So, after submitting the form, do not hide the form, just put a label to submit the success of the message placed on the form, so that the problem solved. At this time, after submitting the form, the page scroll bar does not scroll to the top of the page, still stay in the position of the form, users can immediately see the submission of successful information

Another is to note that the server-side control literal cannot set the CSS, if you want to use literal, but also set the CSS style of the above content, how to do, you can do the following

<asp:literal id="myerror " runat="server">                                 Class="error" >you must choose Recaptcha</label>                            </asp:literal >

Issues encountered while developing the WebForm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.