#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Location
    North Dakota
    Posts
    53
    Rep Power
    14

    call asp function from javascript


    Is there any way to call an asp function/sub routine from javascript code??
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    New York
    Posts
    122
    Rep Power
    14
    In short, no.

    What exactly are you trying to do? There might be a work around.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Posts
    70
    Rep Power
    13
    ...unless your JavaScript is server side. Is that what you mean?

    ...if you mean client side JS then it would have to comunicate with the server to execute any serverside code which means loading a new page.
    Jan.

    N24 - ALL the newspapers on ONE site.
    JMailbox - Free Web Based Email Client.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Location
    North Dakota
    Posts
    53
    Rep Power
    14
    I have several forms, the first 4 are set to no-cache, the 5th is set to cache, and the last 2 are set to no-cache. I have asp code that validates against a database to see if the user has already been to one of those pages. Well since the 5th is cache the asp code does not run after the user has already been there, which lets them reload the page and submit the data again.

    Make sense?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    New York
    Posts
    122
    Rep Power
    14
    Your best bet is to guard against repeat submissions on the server side using a session variable. You could set a variable "submitted" = true on submission and test that submitted equals false before inserting in your db, etc.

    Depending on how the forms are being handled, you could programatically set a client-side js var from you asp that could accomplish the same thing. However, it's a bad practice to rely on client-side code for this sort of thing, so I would go with the session variable or some other server side strategy.

    Good luck.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Posts
    70
    Rep Power
    13
    It sounds very much like you want to prevent an ASP script from running by making sure the page was cached.

    I don't recommend this at all.

    As Szarecor says...better to store the fact that it has run once in a session variable. A client side variable is also not recommended because you are going to be changing pages...so the variable won't persist unless you have it as part of a parent frame.

    Store it in a cookie is also possible.

    Relying on cache is never good. Different browsers begave in different ways...and you can't guarantee that a page is cached or not because the settings can be overriden by the browser.
    Jan.

    N24 - ALL the newspapers on ONE site.
    JMailbox - Free Web Based Email Client.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Location
    North Dakota
    Posts
    53
    Rep Power
    14
    Actually I want to do just the opposite of what you said.

    I have an asp page that must be cached to work properly in NS, (its a table/form and when the user click a button it dynamically adds a new row. Well NS redraws the entire page therefore the page must be cached to retain the values already entered by the user) add therefore the ASP functions don't work, but I want the ASP functions to run even though the page is cached.

IMN logo majestic logo threadwatch logo seochat tools logo