Calling ASP.NET server side subroutine from javascript

Discussion in 'ASP .Net' started by asadikhan, Apr 25, 2004.

  1. asadikhan

    asadikhan Guest

    Hi, I have a timer in javascript on my ASP.NET page. When the time
    expires (a point in my javascript code) I want to call a subroutine
    in my ASP.NET page. But I can't seem to figure out how to do this.

    My subroutine is actually a function I call as a result of a button
    click. But if the user doesn't click the button in the allotted time,
    I want to go ahead and call the function anyways.

    Any idea how I can do this?

    Thanks.

    Asad
     
    asadikhan, Apr 25, 2004
    #1
    1. Advertising

  2. asadikhan

    Bonj Guest

    use the __doPostBack('MyButton', '') javascript function. MyButton is, say,
    an <asp:linkbutton> (definitely works) but I think it can be anything.
    If you look at the html source generated when you run an aspx page you will
    find that this is what asp.net server controls do anyway.
    You can use
    document.forms['Form1'].item('postbackparams').value = arg
    where postbackparams is, say, an <input type="hidden" id="postbackparams">
    to set parameters.



    "asadikhan" <-spam.invalid> wrote in message
    news:408b15c3$1_2@127.0.0.1...
    > Hi, I have a timer in javascript on my ASP.NET page. When the time
    > expires (a point in my javascript code) I want to call a subroutine
    > in my ASP.NET page. But I can't seem to figure out how to do this.
    >
    > My subroutine is actually a function I call as a result of a button
    > click. But if the user doesn't click the button in the allotted time,
    > I want to go ahead and call the function anyways.
    >
    > Any idea how I can do this?
    >
    > Thanks.
    >
    > Asad
    >
     
    Bonj, Apr 25, 2004
    #2
    1. Advertising

  3. Hi

    A simple approach can be to 'refresh' the page when its 'TimeOut' - specify yo Time-Out period in the parameter 'Refresh' of the meta content on top of the page and set its 'content' to say 5 (5 seconds) - this will refresh yo page every 5 seconds ..

    Now on the server side all yo've to do is check fo yo condition(i.e a value in text-box) in 'Page_Load' and call event if its true !!

    Tell me if this doesn't work ()
     
    =?Utf-8?B?SG1udA==?=, Apr 25, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Qw==?=
    Replies:
    1
    Views:
    3,274
    Hermit Dave
    Jan 16, 2004
  2. Roja Doja
    Replies:
    2
    Views:
    3,334
    Roja Doja
    Apr 14, 2005
  3. =?Utf-8?B?S0s=?=
    Replies:
    6
    Views:
    31,805
    errorocean
    Mar 22, 2010
  4. king
    Replies:
    5
    Views:
    210
  5. Replies:
    2
    Views:
    292
Loading...

Share This Page