计时器控制回发问题 [英] Timer controll PostBack Problem

查看:91
本文介绍了计时器控制回发问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Timer Controll来具有计时器功能.我正在使用它的滴答事件.我在一个更新面板中使用它,而在单独的更新面板中使用一些文本框.每当我尝试在文本框中输入一些文本时,光标不会停留在文本框中,并且不允许我输入文本.
aspx代码和.cs代码在下面给出

I am using Timer Controll to have functionality of time counter. I am using its tick event. I am using it in one update panel and some textboxes in separate update panel. WhenEver I try to enter some text in a textBox, cursor doesnot stay in a textBox and it doesnot allow me to Enter Text.
aspx code and .cs code is given below

<div id="TimeDisplayArea">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <contenttemplate>
                <h3>
                    Your Time Left:</h3>
                <div id="DisplayTime">
                    <asp:Label ID="Label1" runat="server" Text="" class="btnType1">
                </div>
                <asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="1000">
                
            </contenttemplate>
        
    </div>


刻度线事件代码:


Tick event Code:

protected void Timer1_Tick(object sender, EventArgs e)
{
    noOfMinutes = Session["TestTime"].ToString();
    this.Label1.Text = "00:00:" + noOfMinutes.ToString();
    Counter = Convert.ToInt16(Session["TestTime"]);
    Counter = Counter - 1;
    Session["TestTime"] = Counter.ToString();
    if (Counter == 0)
    {
        Response.Redirect("Default.aspx");
    }


避免回发的任何帮助.
在此先感谢.
Azhar Iqbal


Any help to avoid postback.
Thanks in Advance.
Azhar Iqbal

推荐答案

在这里,您为计时器1000设置了间隔,即1秒钟.因此,每秒之后将调用Tick事件,并且页面将回发.
做一件事,将TextBox的AutoPostBack属性设置为TRUE,并在该Textbox的TextChenged事件上编写代码以启动计时器.


希望这会有所帮助.


Raju
Here you have given Interval for Timer 1000 it means 1 sec. So after each second the Tick event will be called and page will go for postback.
Do one thing set AutoPostBack Property to TRUE of Textbox and on TextChenged event of that Textbox write code to start the timer.


Hope this may help.


Raju


好,当回发完成并且标签被更新时...您的光标在哪里?
尝试使用javascript更新标签(EnablePartialRendering吗?),以便在输入文本框时不会干扰
well when a postback is done and the label is updated...where is your cursor then?
Try a javascript to update the label (EnablePartialRendering ?) so it does not interfere when typing in a TextBox


这篇关于计时器控制回发问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆