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 8918521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:46:22+00:00 2026-06-15T05:46:22+00:00

If a query string param exists in my page request I want to query

  • 0

If a query string param exists in my page request I want to query the database on the server in the Page_Load and then return the result to the client. I can do the query string param check and query the DB but how do I return the data to the page and on the javascript side how do I access that data?

Ideally I would return JSON of an object structure and it would be returning an array of them.

  • 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-06-15T05:46:24+00:00Added an answer on June 15, 2026 at 5:46 am

    Yes, returning JSON would be the best option. I’m not sure how you query your database (Do you use LINQ or ADO.NET DataTables, etc)

    If you don’t have custom object of type you want to send, I recommend you create one. Then you should get an array of them.

    Example:

    public class Person {
       string Name { get; set; }
       int Age { get; set; }
    }
    
    Person[] pArr = new Person[5];
    

    Then you can use a third party library like this to create an string representaion of that array in JSON.

    string json = JsonConvert.SerializeObject(product);
    

    Then you write that json string to the Response object so its sent down to the client, by overriding the Render method of the page.

    // Don't expect this code to work as it is, but take this as a guidance
    Response.Clear();
    Response.Write(json);
    Response.Close();
    

    on the client side use jQuery library send a request to page, and process the JSON response for you.

    $.getJSON('url', function(data) {
      //process data
    });
    

    Here is my suggestion if you don’t want to use an AJAX request for this:

    Use the objects as you would normally do in the page_load, and convert it to a JSON string as explained above.

    Then use ClientScriptManager to create an JavaScript variable on the client side when it loaded.

    ClientScript.RegisterClientScriptBlock(typeof(Page), "unique_key", "var myObjectList = " + json, true);
    

    After this when the page loads you will have an variable named “myObjectList” with the list of objects without having to make a different AJAX call.

    You can directly refer that variable in your javascript and do necessary processing.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When a user refreshes my page, I want to remove the query string (not
The variable cherrypy.request.params as it is described in the API contains the query string
I have a query string: a=1&b=2&c[1]=3&c[2]=4 etc… I want a NSDictionary where a =>
Does anyone use true or false when setting a query string param for a
The below query is not telling me the username already exists in the database
I have the following method: public static T ExecuteScalar<T>( string query, SqlConnection connection, params
Beside query string root folder how do i get the current doc library list(ListName)
My query string is like: SELECT ... FROM maintable LEFT JOIN table1 on (maintable.id
I have a query string that contains a variable like this $field_name = 'features';
I use query string to access my pages. I try to make if anyone

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.