Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1057085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:48:44+00:00 2026-05-16T17:48:44+00:00

Hi how can I pass a client side (JS) value in server side (C#)?

  • 0

Hi how can I pass a client side (JS) value in server side (C#)?

e.g.

I have a generated table (after uploading images) and it contains images and I want to select the image and throw the ID back in server side.

The uploade I used was JQuery Uploadify and I have a “onComplete” function

(simple code)
'onComplete': function (event, queueID, fileObj, response, data) {
    $('#imgs').append('<img id="' + queueID + '" src="' + response + '" alt="' + response + '" />');

How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:48:44+00:00Added an answer on May 16, 2026 at 5:48 pm

    To send a value from javascript to the server you have a couple of options:

    1. Use AJAX if you want to stay on the current page
    2. Redirect to a server side script and pass the value in the querystring

    Let’s consider the first case:

    Assuming you have a web method capable of receiving the value on the server:

    <%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" %>
    <script type="text/C#" runat="server">
        // Server side script in the code behind that will receive
        // the value: The method needs to be static
        // and decorated with the WebMethod attribute
        [System.Web.Services.WebMethod]
        public static string Foo(string id)
        {
            return "ok";
        }
    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head id="Head1" runat="server">
        <title></title>
        <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
        <script type="text/javascript">
            $(function () {
                // Send an AJAX request to the server
                $.ajax({
                    url: '/default.aspx/foo',
                    type: 'POST',
                    contentType: 'application/json; charset=utf-8',
                    // Pass the value as JSON string
                    // You might need to include json2.js for the JSON.stringify
                    // method: http://www.json.org/json2.js
                    data: JSON.stringify({ id: 'someId123' }),
                    success: function (result) {
                        // The result is also JSON
                        alert(result.d);
                    }
                });
            });
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
    
        </form>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I pass my client-side object to my server object in .net remoting?
How can I pass server side asp control's client ID in javascript function. I
I know that I can use the getParameter() to pass client-side objects, but I
How can i pass value from grid view to a pop up in client
If I have a auto_ptr I can pass it for a reference?Like: auto_ptr<MyClass>Class(new MyClass);
Is there any way that I can pass arguments in selector? example: I have
I have a website which uses SVG for an interactive client side thingamabob. I
I have a JSON object that I need to pass from the server to
I would like to know if we can pass a database table as http
I have some data Foo that I want to pass from the browser to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.