This is a discussion on "Sending objects to the client" within the ASP.NET Forum section. This forum, and the thread "Sending objects to the client are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Sending objects to the client
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Sending objects to the client
Hi there:
I was wondering if there is a better way to send an object to the client than declaring that object as public on the server. I supposed that the request would do that, but apparently the request in C# cannot carry any objects. I don't know if that's an inconvenience that occurs just in C# or it applies to the whole .NET. For example, when I get a result from a query in the database, I store the data into an array, then I'd like to send that array to the client so I can manipulate the html code (via a for routine) in order to show the data within the array. Thanks in advance..... |
|
|
|
|||
|
Re: Sending objects to the client
You may want to look into using AJAX. do a google search for AJAXPro or go to Ajax.net. AJAX allows you to use javascript to send and receive data asyncronosly between client and server.
Also, while you can't send the actual array, you could simply create the html fields you want the data to be in, and simply fill them in from the server. I am not sure why you specifically need to send the array itself to the client. Maybe you can post some sample code of what you are doing. John Ginzo GinzoTech Solutions http://www.ginzotechsolutions |
|
|||
|
Re: Sending objects to the client
Ok, here is some sample code, what I'm doing here in order to manipulate the object on the client is to declare it in the server as public.
<form action="bienes.aspx" method="post" name="form_list"> <div id="list"> <%for(int i=0; i<data.GetLength(0);i++){%> <p> <a onclick="send(<%=data[i,0]%>);" style="cursor </p> <%}%> </div> </form> where "data" has been declared like this: public string[,] data; in the corresponding bienes.aspx.cs file. |
|
|||
|
Re: Sending objects to the client
Well I kind of see what you are trying to do.
However, in .NET you really don't have to "send" that array to the client. Normally, you would add your array to web controls in your cs file, which would render as html when the page gets sent to the client. For example, if the data is just text data, you could create a label, and add your data to the text property of the data in the cs file. If you need the data formatted as a table, you could use the HtmlTable, HtmlTableRow and HtmlTableCell objects in your code to create a table in code, then add it to a placeholder control on the page. I have an example of this on my website at http://ginzotechsolutions.com/Dynami...lsArticle.aspx The bottom line is that you usually do not send raw data to the client. You instead add your data to web controls on the server, and ASP.NET handles rendering them on the client. Hope this helps! John Ginzo GinzoTech Solutions http://www.ginzotechsolutions.com |
|
|||
|
Re: Sending objects to the client
Ok, here's the deal: I already know the objects that .Net comes with, I've used them before, that's why I'm posting this thread. The problem with those is that they are way too big and have too much properties I won't even use, besides the using of those controls creates an ugly javascript code that won't let me validate my pages.
I'm talking about serious server-client programming, very optimized and with a good performance, that's why I wanted to know if it is possible to send objects to the client and then back to the server in .Net. For example I'm using a server page (i.e. that with a .cs extension) to call various client pages (i.e. those with a .aspx extension) according to the case, or in other cases just the opposite various client pages call the same server page, that's why using a .Net control won't help me. Just a final comment: I (along with half the developers in the world) refuse to use tables on my page, I only use them when it's extremely necessary, taht means almost never. Well, hope someone has the answer to my original question, thanks...... |
|
|||
|
Re: Sending objects to the client
>>I'm talking about serious server-client programming, very optimized >>and with a good performance, that's why I wanted to know if it is >>possible to send objects to the client and then back to the server >>in .Net.
I read this in your original post which why I suggested AJAX, which is a technology used to send data and objects asyncronously between client and server, thus accomplishing your task in a serious manner, very optimized and with good performance. You can write all of the code yourself using javascript, or you can use one of the many open source frameworks available. Here is one example of sending an object in this manner. http://www.ajaxpro.info/Examples/Col...s/default.aspx >>Just a final comment: I (along with half the developers in the world) >>refuse to use tables on my page, I only use them when it's >>extremely necessary, taht means almost never. I(along with many developers) use both, depending on the situation. However, I respect your opinion, and using Tables is only one option. If you will notice in my article the checkboxes are added to a table. You could also add them to an html div object on the server, which can then be added to the placeholder. I understand your desire not to use .NET controls in .NET, so this example won't work for you. The only other thing I can suggest is an asyncronous call to the server using callbacks, which is what you can do with AJAX. Maybe someone else has another option? Good Luck to you! John Ginzo GinzoTech Solutions http://www.GinzoTechSolutions.com Last edited by ginzotech; Apr 18th, 2007 at 15:05. |
![]() |
| Tags |
| objects, request, send |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Moving Objects (Not sure if this goes here) | Stormraven | JavaScript Forum | 9 | May 11th, 2008 21:59 |
| client mac address or client HDD serial no | uday | JavaScript Forum | 3 | Apr 18th, 2008 23:22 |
| Removing objects in an array | breepupetstofight | ASP.NET Forum | 0 | Sep 17th, 2007 13:00 |
| Internet Explorer & objects... HELP! | brittny | Web Page Design | 7 | Jul 6th, 2005 23:29 |
| revolving objects | benji | Flash & Multimedia Forum | 5 | Sep 9th, 2003 11:56 |