阿宽

Nothing is more powerful than habit!
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Asp.net自动定义控件在页面中的定位

Posted on 2008-12-01 16:23  宽田  阅读(332)  评论(0编辑  收藏  举报

自己建立了一个控件,上面有显示、隐藏此控件的按钮,现在要当按下这两个按钮时,就定位到此控件的位置,方法如下:

步骤1、在控件的“源码”中加入锚点:

<name="anchorMaintain" id="anchorMaintain"></a>

 

步骤2、
        string script = "<script>function window.onload(){window.location.href='asAnchor';}</script>";
        
this.Page.RegisterStartupScript("asAnchor", script);
这样单击按钮就可以定位到锚点