Search

just show me the code

Wednesday, June 24, 2009

call javascript from code behind

    8     <asp:UpdatePanel ID="UpdatePanel1" runat="server"
    9         UpdateMode="Conditional" >
   10         <ContentTemplate>
   12             <asp:Button ID="Button1" runat="server" Text="Button"
   13                 onclick="Button1_Click" />
   14         </ContentTemplate>
   15     </asp:UpdatePanel>

.................


   17         protected void Button1_Click(object sender, EventArgs e)
   18         {
   21             string script = "alert('Message')";
   22             ScriptManager.RegisterClientScriptBlock(UpdatePanel1,
   23                 typeof(UpdatePanel), "jscript", script, true);
   25         }
 
thanks to link

Tuesday, June 16, 2009

jquery ajax post

....

   93
   94 <div id="Result">Click here for current time</div>

....


   99     <script language="javascript">
  100
  101      //Set up the jQuery Char Counter for text area
  102         $(document).ready(function() {
  104             // Add the page method call as an onclick handler for the div.
  105             $("#Result").click(function() {
  106                 $.ajax({
  107                     type: "POST",
  108                     url: "Main.aspx/GetDate",
  109                     data: "{}",
  110                     contentType: "application/json; charset=utf-8",
  111                     dataType: "json",
  112                     success: function(msg) {
  113                         // Replace the div's content with the page method's return.
  114                         $("#Result").text(msg.d);
  115                     },
  116                     error: function() {
  117                         alert('error');
  118                     } 
  119                 }); 
  120             }); 
  121         });
  122      </script>

Main.aspx.cs ....


   30         [WebMethod]
   31         public static string GetDate()
   32         {
   33             return DateTime.Now.ToString();
   34         }



....

Monday, June 1, 2009

passing data in an ntier application

http://stackoverflow.com/questions/917457



How do you pass data to layers in an n-tier application? I have mapped out 3 different methods.

A) generic .net objects generic data tables, Hashtables, generic datasets, strings, ints etc... then using the datasets to fill your business objects which get sent to the UI layer.

alt text

http://dabbleboard.com/draw?b=eiu165&i=26&c=54eef6f1ac01f03c85919518f4a24e798e57e133

Pro- No extra layers needed Con- Have to work with Generic datasets and tables in the business layer

B) using an entities layer that the other layers would reference. This layer would contain either strongly typed datasets or Plain Old C Objects. The objects would be mostly container data and very little logic. these would be the same objects sent to the UI layer.

alt text

http://dabbleboard.com/draw?b=eiu165&i=6&c=d0c2b346894a96b12bd3867f630e474a2af098fa

Pro- working with the same classes in all layers Con- adding a reference to entities.dll to all layers

C) use data transfer objects (conatiner objects only) defined in the DataAccess Layer. then using those objects to fill business objects which get sent to the UI layer.

alt text

http://dabbleboard.com/draw?b=eiu165&i=27&c=f886efa3f9d5eb4b45ddb02361c79cdcdaec0a9b

Pro- the business layer would not have to work with generic classes Con- working with two types of objects and you would have to hydrate the business objects with the transfer objects

We had a discussion at work and wanted to see what the community thought. I also added a link to the dabbleboard. please copy and create instead of editing.
Thanks

Answer:http://stackoverflow.com/questions/917457

Contributors