In the B/S system, click the screen and locate the object.

Source: Internet
Author: User

How to locate objects in the B/S system
Hbzxf (Hao)
Http://blog.csdn.net/hbzxf/

During the development of the B/S system, due to page refresh issues, the page is often automatically rolled to the beginning. However, sometimes we need to refresh the page and return it to the front of the page. To solve this problem, I wrote a method. You can refer to it. It is not actually a clever method, but at least solved some problems.

The principle is to add an object control at the position you need, so that the control can be located after the page is refreshed, And the scrollintoview method is used.

Public void scrolltoobject (string str_ctl_name, page)
{
If (! Page. isstartupscriptregistered ("scrolobject "))
{
Page. registerstartupscript ("msgscrolobject ","

<SCRIPT> document. forms (0 ). "+ str_ctl_name + ". scrollintoview (); document. forms (0 ). "+ str_ctl_name + ". focus (); </SCRIPT> ");
}
}

Note: scrolltoobject: Method Name
Str_ctl_name: Control name
Example: scrolltoobject (button1, page );

You can use the anchor in HTML to locate the DataGrid. For specific operations, refer to the HTML manual to learn how to use the anchor.

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.