Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I'm writing a order taking system using JQuery and ASP.NET. I'm also using JSGrid, which when provided with an array will display the data in a nice looking grid.

Within the project I'm using jquery.ajax and JSON to return various data as I need it. e.g. when the product code is entered I return a list of stock locations. Everything is working fine when adding a new order. But if I want to return to an existing order then I need to fill my javascript array with data, so that grid can be populated.

I could put a jquery.ajax request on the load event but this doesn't seem right - returning to the server to collect data after the page as loaded into the browser, it's a return trip for no reason, even if it is async.

Is there a way to send the order data to the javascript array when the page is first requested? I'm sure their must be, after all I'm sending the html and javascript, but I'm not sure which approach to use. ClientScript.RegisterClientScriptBlock from code behind appears promising. Is this a good route, or are there better ways?

What I have tried:

I've not tried much as I don't really know where to start. Looking for ideas and advice.
Posted
Updated 21-Sep-18 0:07am
v4
Comments
F-ES Sitecore 21-Sep-18 6:35am    
As long as the javascript array is defined on the page itself and not in a js file then you can do this. Your asp.net code doesn't output javscript or html or whatever, it simply outputs text, so however you want the array to look when the page loads make sure it looks like that. So if it has to look like

var myData = [1,2,3,4];

and "1", "2", "3" etc are data from your database then make sure the output has that data, so you could build the data in a string variable called MyDataAsString and output it like

var myData = [<%=MyDataAsString %>];
Laxmidhar tatwa technologies 29-Sep-18 6:59am    
hiactualy first excute serverside then client side.
so jquery is best

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900