November 2008 - Posts

jquery and UI templating!!

jquery could be very much helpful while performing templating i.e. rendering controls. 

I've followed the following steps for doing this.

1. on document ready function of jquery, I called its ajax behaviour.

 

 


  1. $(document).ready(function(){

  2.     $.ajax({
  3.         type:"POST",
  4.         url:"test.asmx/GetListData",
  5.         data:"{}",
  6.         contentType:"application/json; charset=utf-8",
  7.         dataType:"json",
  8.         success:function(msg){

  9.         $('#listData').removeClass('loading');
  10.         $('#listData').html(msg);
  11.     }
  12.     });

  13. });

 

 

 

2.  then, i created a usercontrol which contains datalist for templating.

on its code behind i wrote following code.

 

 

  1.          public object Data;
  2.         protected void Page_Load(object sender, EventArgs e)
  3.         {
  4.             DataList1.DataSource = Data;
  5.             DataList1.DataBind();
  6.         }

 

3. after that i created a webservice and passed the usercontrol path and data to ViewManager's Render method. This resembles with MVC which is booming in asp.net these days.

 

 

  1.  NorthWindDataset.CategoriesDataTable dt = new NorthWindDataset.CategoriesDataTable();

  2.             CategoriesTableAdapter da = new CategoriesTableAdapter();
  3.             dt = da.GetData();

  4.             if (dt.Count > 0)
  5.             {
  6.                 return ViewManager.RenderView("~/UserControls/listData.ascx", dt);
  7.             }
  8.             else
  9.             {
  10.                 return ViewManager.RenderView("~/UserControls/listData.ascx", null);
  11.             }

 

 

 

Finally, I ran my code. it worked great and superfast to asp.net ajax style. Just download the sample below and judge yourself.

 

download source code: jqajax.zip

 

Getting started with WWF

 it 's true, a single picture speaks thousand words. visual studio has this feature called work flow foundation to prove this in programming. Basically there are two type of work flows in visual studio . i) sequential workflow and ii) state machine workflow.

I'll show you, how to create a simple wwf application, and I start for simple file checking application where first,  i check for file either exists or not, after that i check its size and write proper message for UI.

1. create a WWF sequential class library project.

 

2. add a new item of sequential workflow(code) class. or you can use (XOML) either way.

 

3. add code activity and ifelse acitivity controls from toolbox and give proper name as below.

4. double click the code activity block and write your code there  to control your logic.

5. specify the if else condition using either declarative method or using code or both. I'm using both, below is declarative method.

 

5. Finally I used it in my windows form application. That's it. How easy it is!!

 

source code: wwf.zip

 

Posted by Padam Raj Gurung with no comments