本文介绍了如何在计时器结束时创建计时器并执行某些操作。为了实现这一点,我想在Mvc应用程序中使用Wcf服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i have to activate submit button when timer reaches to 00:00:000 and send the information to save in database using wcf service in my mvc application pls tell me how can i achieve this. i am new to wcf and mvc
i have to start timer on .cshtml view page of my mvc application the way asp timer starts on page_load of asp.net application .for this i want to use controller action method and i am desparate to do it using wcf service










<pre lang="xml"><asp:UpdatePanel ID="up"  UpdateMode="Conditional"  runat="server">
        <Triggers>
        <asp:AsyncPostBackTrigger ControlID="tm" EventName="Tick" /></Triggers>
        <ContentTemplate>
           <div style="position:absolute;   top: 265px; left: 600px; height: 20px;  width:150px; " id="col" runat="server">
                <asp:Label ID="lbtime" Font-Bold="true"  Width="100"  ForeColor="White" runat="server" ></asp:Label></div>


<asp:Label ID="lbtime0" runat="server" Font-Bold="true" ForeColor="Black" ></asp:Label>
            </ContentTemplate>
            </asp:UpdatePanel></pre>
in code behind

<pre lang="cs"> rotected void Timer_Tick(object sender, EventArgs e)
  {
  //  lbtime.Visible = true;
        if (sender == tm)
        {

            string s = Convert.ToString(Request.Cookies["Contest"].Value);
            sqlread = dclass.GetRead("select * from CEntry where ContestTitle='" + Request.Cookies["Contest"].Value + "'");
            if (sqlread.Read())
            {
                DateTime startDate = System.DateTime.Now;
                DateTime timetoexpirecontest = Convert.ToDateTime(sqlread["Duration"]);

                TimeSpan t = timetoexpirecontest - startDate;
                // TimeSpan t2 = new TimeSpan(11,0,0);
                //   t = t.Add(t2);
 if (t.Days <= 0 && t.Hours <= 0 && t.Minutes <= 0 && t.Seconds <= 0)

                {

                    //countdown action

                       //disable button

                 }

               }

             }

}</pre>






















i want to achieve timer tick event means above mention thing in mvc 's controller action method
and that too using wcf service that's why tell me every thing means where to set timer ,how to coutdown it dynamically using database in mvc 3.0 razor with wcf

推荐答案

这篇关于如何在计时器结束时创建计时器并执行某些操作。为了实现这一点,我想在Mvc应用程序中使用Wcf服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 22:51