Good question!!!!

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.



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to