Get values from javascript array using

Posted on 2010-01-03
Last Modified: 2013-11-07
I am  using javascript array and want to read the value of the array using code behind
Question by:dba_damion
    LVL 35

    Expert Comment

    by:Miguel Oz
    If you are using use:

    LVL 4

    Expert Comment

    hi dba_damion,

    As per my understanding, your requirement is to read the client-side value (javascript array) in the server-side (using code behind).. if so, as per my knowledge... we can't directly read a client-side value in the server-side.

    My suggestion is that, put that javascript array to a hidden field (server side) and read the value from that hidden field control.

    Author Comment

    My main goal is to make a form using and aspx that will allow the user to populate the form (using next , previous , process all button) with out posting the value back to the server each time . I want them to only send a batch of data to the server when they hit the process all button
    LVL 35

    Expert Comment

    by:Miguel Oz
    Ok, if that is the case,
    Alternative 1:
    You do not need an array, you only have 3 values that you can send as a parameters of a query string.
    In js call your your page like 1.aspx?next=v1&previous=v2&process=v3"
    In access page_load event access Request property (Request["next"].ToString())

    Alternative 2: A lot of work for no real gain.
    In java script:
    you still need to convert your js array into comma separated values (arrayStr = p1,p2,p3)
    and assigned as query string like 1.aspx?file=" + arrayStr
    In your page_load event:
    string[] files = Request["file"].ToString().Split(',');
    ArrayList arry = new ArrayList();
    foreach (string file in files)

    Let me know which solution fits you. I can translate the code to if required.


    Author Comment

    I found another way to go is using Ajax components with script manager.  This will be best for me but I am not sure how to use this . I want to insert data in the top part of the page while the grid is updated with out reloading the page can someone help
    LVL 2

    Expert Comment

    Hey damion, I've worked on a similar issue using .net callbacks which is similar to Ajax. If i understand what you're trying to do,  you want to be able to asynchronously (without a postback or page refresh) send data from the Equipment, Revenue Date, etc. fields to the server and then get data back to the server which will then be used to update the grid? But to have this all operate seamlessly so the user doesn't feel they've gone from one page to the next?  If that's what you're trying to do Callbacks will help, it's a lot like Ajax but you have to some of the coding manually that Ajax abstracts away. But it does give you full control. Are you committed to strictly using Ajax?

    Accepted Solution

    I figured it out updatepanel in vs2005 did the trick

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now