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.