Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Can I trigger a function in asp.net?

Can I trigger a function in asp.net?

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasequestion
26 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Pankaj Garg

    timer control will sort this problem out.

    If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

    A Offline
    A Offline
    Abhijit Jana
    wrote on last edited by
    #3

    Pankaj Garg wrote:

    timer control will sort this problem out.

    Sure and use eventhandler and Deleget that function on Timer_Tick

    Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

    P 1 Reply Last reply
    0
    • P Pankaj Garg

      timer control will sort this problem out.

      If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

      H Offline
      H Offline
      hogan john
      wrote on last edited by
      #4

      I think the timer control won't work. The timer works only the page which contains the times runs. Thanks Hogan

      A P 2 Replies Last reply
      0
      • H hogan john

        I think the timer control won't work. The timer works only the page which contains the times runs. Thanks Hogan

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #5

        hogan.john wrote:

        The timer works only the page which contains the times runs.

        can you explain in details ???

        Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

        H 1 Reply Last reply
        0
        • H hogan john

          My requirment is that I want to run a function in a class automatically every 30 days. But as per my understanding, the asp.net application runs only when someone request any pages in that site through the browser. Is it correct? Can i set any triggers in asp.net? Thanks and regards, Hogan

          M Offline
          M Offline
          Malcolm Smart
          wrote on last edited by
          #6

          hogan.john wrote:

          My requirment is that I want to run a function in a class automatically every 30 days

          That doesn't sound like a good job for a webserver to be honest. Can't you wrap the method call and use windows scheduler, or a windows service to run the call for you?

          Small angry dogs

          H 1 Reply Last reply
          0
          • A Abhijit Jana

            hogan.john wrote:

            The timer works only the page which contains the times runs.

            can you explain in details ???

            Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

            H Offline
            H Offline
            hogan john
            wrote on last edited by
            #7

            Sorry I am not an expert. But it is the client-server technology. I think, the executables in the bin folder only work whenever a browser requests any pages in that site. Hope I am clear now. Thanks, Hogan

            1 Reply Last reply
            0
            • H hogan john

              I think the timer control won't work. The timer works only the page which contains the times runs. Thanks Hogan

              P Offline
              P Offline
              Pankaj Garg
              wrote on last edited by
              #8

              Try this link

              If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

              H 1 Reply Last reply
              0
              • M Malcolm Smart

                hogan.john wrote:

                My requirment is that I want to run a function in a class automatically every 30 days

                That doesn't sound like a good job for a webserver to be honest. Can't you wrap the method call and use windows scheduler, or a windows service to run the call for you?

                Small angry dogs

                H Offline
                H Offline
                hogan john
                wrote on last edited by
                #9

                But how can i implement a windows service in the remote host machine? Thanks Hogan

                A 1 Reply Last reply
                0
                • P Pankaj Garg

                  Try this link

                  If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                  H Offline
                  H Offline
                  hogan john
                  wrote on last edited by
                  #10

                  Thanks to spend time with me Pankaj. But I am afraid that it won't work automatically Regards, Hogan

                  1 Reply Last reply
                  0
                  • A Abhijit Jana

                    Pankaj Garg wrote:

                    timer control will sort this problem out.

                    Sure and use eventhandler and Deleget that function on Timer_Tick

                    Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

                    P Offline
                    P Offline
                    Pankaj Garg
                    wrote on last edited by
                    #11

                    i was using the timer control in website just for the practise purposes.I saw , the timer control is auto executing after it's time interval if it is a ajax enabled website. If it is a asp.net we site(partially enabled ajax website , i mean , in the asp.net website , i am dragging the ajax controls) then the timer control is not working , it works if in the form load i write protected void Page_Load(object sender, EventArgs e) { Timer1_Tick(sender, e); } the source file code <form id="form1" runat="server"> <div> &nbsp;<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick"> </asp:Timer> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> </asp:UpdatePanel> </form> I am unable to understand where i am wrong ?

                    If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                    1 Reply Last reply
                    0
                    • H hogan john

                      My requirment is that I want to run a function in a class automatically every 30 days. But as per my understanding, the asp.net application runs only when someone request any pages in that site through the browser. Is it correct? Can i set any triggers in asp.net? Thanks and regards, Hogan

                      A Offline
                      A Offline
                      Abhijit Jana
                      wrote on last edited by
                      #12

                      I am sorry for misunderstanding the requirment . I thought it was 30 min. it is 30 day !!! if you are try to use Timer ... this is a very bad approch!!! best use Windows Services as malcolm suggested...

                      Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

                      P 1 Reply Last reply
                      0
                      • H hogan john

                        But how can i implement a windows service in the remote host machine? Thanks Hogan

                        A Offline
                        A Offline
                        Abhijit Jana
                        wrote on last edited by
                        #13

                        Can you tell me what kind of function is this or what is the object of this function ? is it database related ???

                        Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

                        H 1 Reply Last reply
                        0
                        • A Abhijit Jana

                          I am sorry for misunderstanding the requirment . I thought it was 30 min. it is 30 day !!! if you are try to use Timer ... this is a very bad approch!!! best use Windows Services as malcolm suggested...

                          Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

                          P Offline
                          P Offline
                          Pankaj Garg
                          wrote on last edited by
                          #14

                          i was using the timer control in website just for the practise purposes.I saw , the timer control is auto executing after it's time interval if it is a ajax enabled website. If it is a asp.net web site(partially enabled ajax website , i mean , in the asp.net website , i am dragging the ajax controls) then the timer control is not working , it works if in the form load i write protected void Page_Load(object sender, EventArgs e) { Timer1_Tick(sender, e); } the source file code <form id="form1" runat="server"> <div> &nbsp;<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick"> </asp:Timer> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> </asp:UpdatePanel> </form>I am unable to understand where i am wrong ?

                          If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                          A 1 Reply Last reply
                          0
                          • A Abhijit Jana

                            Can you tell me what kind of function is this or what is the object of this function ? is it database related ???

                            Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

                            H Offline
                            H Offline
                            hogan john
                            wrote on last edited by
                            #15

                            a function written in a class. Just like this... class test { public void show(){} }

                            modified on Tuesday, January 15, 2008 3:36:12 AM

                            A 1 Reply Last reply
                            0
                            • P Pankaj Garg

                              i was using the timer control in website just for the practise purposes.I saw , the timer control is auto executing after it's time interval if it is a ajax enabled website. If it is a asp.net web site(partially enabled ajax website , i mean , in the asp.net website , i am dragging the ajax controls) then the timer control is not working , it works if in the form load i write protected void Page_Load(object sender, EventArgs e) { Timer1_Tick(sender, e); } the source file code <form id="form1" runat="server"> <div> &nbsp;<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick"> </asp:Timer> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> </asp:UpdatePanel> </form>I am unable to understand where i am wrong ?

                              If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                              A Offline
                              A Offline
                              Abhijit Jana
                              wrote on last edited by
                              #16

                              Pankaj Garg wrote:

                              protected void Page_Load(object sender, EventArgs e) { Timer1_Tick(sender, e); }

                              This is not the way delegate a fuction !!!! Check this one :) protected void Page_Load(object sender, EventArgs e) { Timer1.Tick += new EventHandler<EventArgs>(Timer1_Tick); } void Timer1_Tick(object sender, EventArgs e) { Label1.Text = System.DateTime.Now.ToLongTimeString(); } ;)

                              Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

                              P 1 Reply Last reply
                              0
                              • H hogan john

                                a function written in a class. Just like this... class test { public void show(){} }

                                modified on Tuesday, January 15, 2008 3:36:12 AM

                                A Offline
                                A Offline
                                Abhijit Jana
                                wrote on last edited by
                                #17

                                hogan.john wrote:

                                a function written in a class. Just like this... class test { public void show(){} }

                                This is normal function !!! but i want to know why you want to execute it after 30 day . It should be special reason , then we can think a differnt apporch as per requirment :)

                                Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

                                H 1 Reply Last reply
                                0
                                • A Abhijit Jana

                                  Pankaj Garg wrote:

                                  protected void Page_Load(object sender, EventArgs e) { Timer1_Tick(sender, e); }

                                  This is not the way delegate a fuction !!!! Check this one :) protected void Page_Load(object sender, EventArgs e) { Timer1.Tick += new EventHandler<EventArgs>(Timer1_Tick); } void Timer1_Tick(object sender, EventArgs e) { Label1.Text = System.DateTime.Now.ToLongTimeString(); } ;)

                                  Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

                                  P Offline
                                  P Offline
                                  Pankaj Garg
                                  wrote on last edited by
                                  #18

                                  protected void Page_Load(object sender, EventArgs e) { Timer1.Tick += new EventHandler<EventArgs>(Timer1_Tick); Timer1.Enabled = true; } protected void Timer1_Tick(object sender, EventArgs e) { i += 0; Label1.Text = i.ToString(); } I think after writing the code , the control should auto execute the timer_tick function. But the control is not comming there. the time interval is 1000.

                                  If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                                  A 1 Reply Last reply
                                  0
                                  • P Pankaj Garg

                                    protected void Page_Load(object sender, EventArgs e) { Timer1.Tick += new EventHandler<EventArgs>(Timer1_Tick); Timer1.Enabled = true; } protected void Timer1_Tick(object sender, EventArgs e) { i += 0; Label1.Text = i.ToString(); } I think after writing the code , the control should auto execute the timer_tick function. But the control is not comming there. the time interval is 1000.

                                    If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                                    A Offline
                                    A Offline
                                    Abhijit Jana
                                    wrote on last edited by
                                    #19

                                    what out comes are you getting in label ??? i think only 0 .

                                    Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

                                    P 1 Reply Last reply
                                    0
                                    • A Abhijit Jana

                                      hogan.john wrote:

                                      a function written in a class. Just like this... class test { public void show(){} }

                                      This is normal function !!! but i want to know why you want to execute it after 30 day . It should be special reason , then we can think a differnt apporch as per requirment :)

                                      Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

                                      H Offline
                                      H Offline
                                      hogan john
                                      wrote on last edited by
                                      #20

                                      Ok :) My purpose is to send monthly new letters to every registered members at the end of the month

                                      A 1 Reply Last reply
                                      0
                                      • A Abhijit Jana

                                        what out comes are you getting in label ??? i think only 0 .

                                        Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

                                        P Offline
                                        P Offline
                                        Pankaj Garg
                                        wrote on last edited by
                                        #21

                                        Label text was Label initially at runtime it is Label after form load.

                                        If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                                        A 1 Reply Last reply
                                        0
                                        • P Pankaj Garg

                                          Label text was Label initially at runtime it is Label after form load.

                                          If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                                          A Offline
                                          A Offline
                                          Abhijit Jana
                                          wrote on last edited by
                                          #22

                                          you are using ajaexenabled websites na !!!! use ajax enabled sites. and dont initilize local variable inside the Timer_Tick(), because it will remain same :) let me know if any problems

                                          Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"

                                          P 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups