国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

通過自定義類來達到向aspx頁面加入腳本代碼的例子

2024-05-04 11:06:29
字體:
來源:轉載
供稿:網友
set the initialfocus for an asp.net webform
the pageutil class has a static method setinitialfocus(control) which can be used to generate a javascript for an asp.net page (webform), which sets the focus on a (given) control.

        private void page_load(object sender, system.eventargs e)
        {
            // set the initialfocus on textbox1
            pageutil.setinitialfocus(textbox1);




using system;
using system.web.ui;

namespace initialfocusdemo
{
    /// <summary>
    /// utility class for a asp.net page
    /// </summary>
    public class pageutil
    {

        /// <summary>
        /// set the intialfocus to the given control. only works when javascript is supported.
        /// </summary>
        /// <param name="control">control to set the initialfocus on.</param>
        public static void setinitialfocus(control control) {
            if (control.page == null) {
                throw new argumentexception("the control must be added to a page before you can set the intialfocus to it.");
            }
            if (control.page.request.browser.javascript == true) {
                control.page.registerclientscriptblock("initialfocus",
                "<script for='window' event='onload' language='jscript'>document.all."
                + control.uniqueid + ".focus();</script>");
            }
        }

    }
}
 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 珲春市| 大英县| 图们市| 华蓥市| 南投市| 新源县| 精河县| 泰顺县| 华容县| 荔浦县| 慈利县| 陕西省| 大同县| 玉山县| 旌德县| 敦化市| 治多县| 蒙山县| 红桥区| 三穗县| 汶川县| 雅安市| 胶州市| 嘉定区| 天气| 长乐市| 城固县| 朔州市| 鄱阳县| 滁州市| 万载县| 衡阳市| 望奎县| 天峨县| 铜陵市| 社会| 郴州市| 肥城市| 南川市| 布尔津县| 荆州市|