How do I pass data back to my code behind events w/o postback?

Discussion in 'Javascript' started by Mike, Nov 13, 2004.

  1. Mike

    Mike Guest

    I have an ASP.NET webform that has an HTML button (with an onClick
    event that calls a javascript function) and a Web Forms button (the
    code behind click event saves data back to a SQL DB).

    The javascript function basically creates a variable such as:

    var someStrings = "foo1.jpg,foo2.jpg,foo3.jpg,foo4.jpg"

    I really need to be able to access this javascript variable from the
    Click event of my Web Forms button so that I can pull the file names
    out of this string and do some database work on them.

    Any ideas? I've thought of putting a web forms textbox on the form
    and having my javascript function place the string contents in there
    which is easily accessible by my web forms button click event, however
    now I have an unsightly textbox that should not be on my form.

    Is there an easier way to access the contents of a javascript
    (client-side) variable from the click event of my web forms button?

    Thanks!
    Mike, Nov 13, 2004
    #1
    1. Advertising

  2. I am not an ASP programmer but have had a similar need using other
    technologies.

    Unless I am failing to understand what you want to do you could also
    have ASP create the JavaScript variable for you. You could certainly
    store the strings in a form field, hidden or otherwise, but you could
    also do this:

    var someStrings = "<% ASP code here to output the strings %>";

    The ASP code to generate the strings is executed on the server and will
    be done before the browser reads in the JavaScript code your ASP code
    generated.

    Mike wrote:

    >I have an ASP.NET webform that has an HTML button (with an onClick
    >event that calls a javascript function) and a Web Forms button (the
    >code behind click event saves data back to a SQL DB).
    >
    >The javascript function basically creates a variable such as:
    >
    >var someStrings = "foo1.jpg,foo2.jpg,foo3.jpg,foo4.jpg"
    >
    >I really need to be able to access this javascript variable from the
    >Click event of my Web Forms button so that I can pull the file names
    >out of this string and do some database work on them.
    >
    >Any ideas? I've thought of putting a web forms textbox on the form
    >and having my javascript function place the string contents in there
    >which is easily accessible by my web forms button click event, however
    >now I have an unsightly textbox that should not be on my form.
    >
    >Is there an easier way to access the contents of a javascript
    >(client-side) variable from the click event of my web forms button?
    >
    >Thanks!
    >
    >
    Scott Orsburn, Nov 23, 2004
    #2
    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. Ben Miller [msft]

    Re: Code Behind vs. no code behind: error

    Ben Miller [msft], Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    556
    Alphonse Giambrone
    Jun 28, 2003
  2. John

    Non-code behind to code behind

    John, Feb 19, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    452
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 19, 2007
  3. Ed Cayce
    Replies:
    0
    Views:
    898
    Ed Cayce
    Aug 8, 2009
  4. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    327
    Chris
    Aug 30, 2005
  5. David Thielen

    pop-up browser persist data back to parent page code-behind

    David Thielen, Mar 23, 2006, in forum: ASP .Net Web Controls
    Replies:
    7
    Views:
    168
    Steven Cheng[MSFT]
    Mar 29, 2006
Loading...

Share This Page