Groups > Asp .Net > ASP.NET Atlas Framework discussion > Re: timer control in a custom control




timer control in a custom control

timer control in a custom control
Mon, 25 Sep 2006 16:41:07 +000
Hello everyone, I have a problem w/ the timer control.  It works fine in a
normal aspx page, but when I use it in a custom control, it will continueally do
normal postbacks.  

 

any one have any ideas?

 

here are the lines from the custom control 

            tmrTime.ID = "tmrTime";
            tmrTime.Interval = 2000;
            tmrTime.Enabled = true;
            tmrTime.Tick += new EventHandler(tmrTime_Tick);
            upUpdate.Content.Controls.Add(tmrTime);
Post Reply
Re: timer control in a custom control
Mon, 25 Sep 2006 20:07:15 +000
as follow up I have also moved the timer out of the update panel and added a
triger w/ the same results. the timer will continually send normal non atlas
postbacks once the timercontrol is added.

 see new code below

            tmrTime.ID = "tmrTime";
            tmrTime.Interval = 2000;
            tmrTime.Enabled = true;
            tmrTime.Tick += new EventHandler(tmrTime_Tick);
            Controls.Add(tmrTime);

            trTime = new ControlEventTrigger();
            trTime.ControlID = "tmrTime";
            trTime.EventName = "Tick"; 

            upUpdate.Triggers.Add(trTime);
Post Reply
Re: timer control in a custom control
Mon, 25 Sep 2006 21:37:08 +000
hello.

well, could you tell us where you're using that code? maybe you could also put a
small demo page here?
Post Reply
Re: timer control in a custom control
Tue, 26 Sep 2006 13:13:23 +000
the code is with in a custom control... I can get the timer control to work just
fine w/ in a standard aspx page, but when I place it in a control and then place
that control on a page, it will continuelly do a traditional postback when the
timer ticks.  Below is some code from said custom control.

 Is there any reason why an atlas timer control would ever do a traditional
postback instead of being caught by atlas?
 

        protected Button btnLogin = new Button();
        protected Button btnSubmit = new Button();
        protected TextBox txtLogin = new TextBox();
        protected TextBox txtMsg = new TextBox();
        protected Label lblResponse = new Label();
        protected MultiView mvPages = new MultiView();
        protected View vwLogin = new View();
        protected View vwMain = new View();
        internal MyObj.CompositionUpdatePanel upUpdate;
        protected Microsoft.Web.UI.ControlEventTrigger trTime;
        protected Microsoft.Web.UI.ControlEventTrigger trLogin;
        protected Microsoft.Web.UI.ControlEventTrigger trSend;
        protected Microsoft.Web.UI.Controls.TimerControl tmrTime = new
Microsoft.Web.UI.Controls.TimerControl();

        protected override void CreateChildControls()
        {
            
            upUpdate = new CompositionUpdatePanel(this);
            upUpdate.ID = "upChatPanel";
            upUpdate.Mode = UpdatePanelMode.Conditional;
            upUpdate.RenderMode = UpdatePanelRenderMode.Block;
            upUpdate.EnableViewState = true;

            Controls.Add(upUpdate);

            txtLogin.ID = "txtLogin";
            btnLogin.ID = "btnLogin";
            btnLogin.CommandName = "login";
            btnLogin.Text = "login";

            vwLogin.Controls.Add(txtLogin);
            vwLogin.Controls.Add(btnLogin);

            lblResponse.ID = "lblResponse";
            txtMsg.ID = "txtMessage";
            btnSubmit.ID = "btnSubmit";
            btnSubmit.CommandName = "submit";
            btnSubmit.Text = "send";

            vwMain.Controls.Add(lblResponse);
            vwMain.Controls.Add(txtMsg);
            vwMain.Controls.Add(btnSubmit);

            mvPages.Views.Add(vwLogin);
            mvPages.Views.Add(vwMain);
            mvPages.SetActiveView(vwLogin);

            upUpdate.Content.Controls.Add(mvPages);

            trTime = new ControlEventTrigger();
            trTime.ControlID = "tmrTime";
            trTime.EventName = "Tick";

            trLogin = new ControlEventTrigger();
            trLogin.ControlID = "btnLogin";
            trLogin.EventName = "Command";

            trSend = new ControlEventTrigger();
            trSend.ControlID = "btnSubmit";
            trSend.EventName = "Command";

            upUpdate.Triggers.Add(trLogin);
            upUpdate.Triggers.Add(trSend);
            upUpdate.Triggers.Add(trTime);


            tmrTime.ID = "tmrTime";
            tmrTime.Interval = 2000;
            tmrTime.Enabled = true;
            tmrTime.Tick += new EventHandler(tmrTime_Tick);
            Controls.Add(tmrTime);

            ChildControlsCreated = true;
        }
Post Reply
Re: timer control in a custom control
Tue, 26 Sep 2006 17:18:47 +000
hello.

though i might be mistaken, i'd say that is the normal behavior (ie, the timer
does starta postback when it's put in a page)...
Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact