zoukankan      html  css  js  c++  java
  • timer 焦点

    function txtFocus()
            {
                var exp=new Date();
                exp.setTime(exp.getTime() + 60*60*1000);
                document.cookie = "focusTextBox="+ event.srcElement.id + ";expires=" + exp.toGMTString();
            }


               <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <div>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server" OnInit="UpdatePanel1_Init">
                    <ContentTemplate>
                    <asp:TextBox runat=server ID=zwei Columns="10" Rows="10" TextMode="MultiLine"></asp:TextBox>
                        <asp:Timer ID="Timer1" runat="server" Interval="5000">
                        </asp:Timer>
                    </ContentTemplate>
                </asp:UpdatePanel>
           
           
            </div>

    protected void Page_Load(object sender, EventArgs e)
        {
            this.zwei.Attributes.Add("onfocus","txtFocus()");
        }
        protected void UpdatePanel1_Init(object sender, EventArgs e)
        {
            if (this.Request.Cookies["focusTextBox"] != null)
            {
                string s = this.Request.Cookies["focusTextBox"].Value;//读出post之前光标停留在哪个TextBox之中
                string script =
                "var inp = $get('" + s + "');" +
                "window.setTimeout('var r = inp.createTextRange();r.collapse(false);r.select();', 10);";
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.Page.GetType(), "ScriptBlock", script, true);
            }

        }

  • 相关阅读:
    Centos 安装git
    mybatis 整合redis作为二级缓存
    jedis 连接池工具类
    IE8下使用asp.net core mvc+jquery ajaxSubmit问题
    .net core mvc部署到IIS导出Word 提示80070005拒绝访问
    IdentityServer4在Asp.Net Core中的应用(三)
    理解OpenID和OAuth的区别
    IdentityServer4在Asp.Net Core中的应用(二)
    使用Bind读取配置到C#的实例
    IdentityServer4在Asp.Net Core中的应用(一)
  • 原文地址:https://www.cnblogs.com/zwei1121/p/1238791.html
Copyright © 2011-2022 走看看