国产探花免费观看_亚洲丰满少妇自慰呻吟_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>");
            }
        }

    }
}
 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 息烽县| 湟源县| 利辛县| 南召县| 海宁市| 抚松县| 博湖县| 上虞市| 迁安市| 定日县| 日照市| 千阳县| 漠河县| 丹东市| 万荣县| 道真| 昭苏县| 伊春市| 沾化县| 湟源县| 辽宁省| 筠连县| 商丘市| 丹凤县| 青龙| 雷山县| 叶城县| 安西县| 贺兰县| 遵化市| 东辽县| 凉城县| 阿鲁科尔沁旗| 海晏县| 威海市| 高阳县| 上犹县| 余庆县| 东阿县| 白城市| 建阳市|