Hi David,
I prefer the second one, but not 100% the same. I'd like to return
only data that will be visible. Then I will get some more lines to be
fast when clicking on "next" or "prev". Let us say you want to creater
maszer-detail views, than you are very happy with this. Instead of
creting a big html stringbI prefer the use of the DOM. I hope I can
put a demo video online tomorrow to show an interested web site I'm
currently developing, it's an intranet application.
Michael
On 10/10/06, David <[EMAIL PROTECTED]> wrote:
>
> Hi Michael.
>
> I recently read an old post written by you where you said: "I developed
> Ajax.NET to have the
> minimal of data that must be send from the server to the client."
> this post was about using or not HtmlControlsUpdate, and you also said:
> "I "hate" the HtmlControls because I never used them. I'm using
> JavaScript on the client-side and with that I can build every HTML
> control. So, the prefered way is to build JavaScript instead of sending
> the HTML source code of rendered web controls."
>
> So, let me ask you something, if you want to have a datagrid in your
> page, wich of this two cases would you use? AND WHY?
>
> Case 1 (RenderControl):
> Javascript:
> function datagrid_callback(res)
> {
> document.getElementById('mydg').innerHTML = res.value;
> }
> function datagrid(indice)
> {
> Methods.Datagrid(datagrid_callback);
> }
> ServerSide (C#):
> [AjaxMethod]
> public string Datagrid()
> {
> DataSet ds = new DataSet();
> DataGrid dg = new DataGrid();
> dg.DataSource = ds;/*some data*/
> //...
> dg.DataBind();
> StringBuilder sb = new StringBuilder();
> StringWriter stWriter = new StringWriter(sb);
> HtmlTextWriter htmlWriter = new HtmlTextWriter(stWriter);
> dg.RenderControl(htmlWriter);
> return sb.ToString();
> }
>
> Case 2 (Javascript):
> function datagrid_callback(res)
> {
> var ds = res.value.Tables[0];
> var html = [];
> html[html.length] = '<table">';
> //...
> //generate the rows of the table
> //...
> html[html.length] = '</table>';
> document.getElementById("mydg").innerHTML = html.join("");
> }
> function datagrid()
> {
> Metodos.Datagrid(datagrid_callback);
> }
> ServerSide (C#):
> [AjaxMethod]
> public DataSet Datagrid()
> {
> SqlConnection conn = new SqlConnection("..");
> SqlCommand cmd = new SqlCommand("some query", conn);
> ...
> SqlDataAdapter da = new SqlDataAdapter(cmd);
> DataSet ds = new DataSet();
> try
> {
> conn.Open();
> try
> {
> da.Fill(ds);
> }
> catch (Exception)
> { }
> finally
> {
> conn.Close();
> conn.Dispose();
> }
> }
> catch (Exception)
> { }
> return ds;
> }
>
> Thanks for being here for us.
>
>
> >
>
--
Best regards | Schöne Grüße
Michael
Microsoft MVP - Most Valuable Professional
Microsoft MCAD - Certified Application Developer
http://weblogs.asp.net/mschwarz/
http://www.schwarz-interactive.de/
Skype: callto:schwarz-interactive
MSN IM: [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ajax.NET Professional" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/ajaxpro
The latest downloads of Ajax.NET Professional can be found at
http://www.ajaxpro.info/
Don't forget to read my blog at http://weblogs.asp.net/mschwarz/
The open source project is now located at
http://www.codeplex.com/Wiki/View.aspx?ProjectName=AjaxPro
-~----------~----~----~----~------~----~------~--~---