Click here to Skip to main content
15,886,362 members
Articles / Web Development / ASP.NET

Flexible Web UI Workflow application through ASP.NET MVC & Windows Workflow Foundation

Rate me:
Please Sign up or sign in to vote.
4.68/5 (20 votes)
3 Sep 2009CPOL10 min read 165.8K   9.8K   53  
An article on developing a flexible web UI workflow application, using ASP.NET MVC & Windows Workflow Foundation
//----------------------------------------------------------
// Copyright (C) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------
// MicrosoftMvcAjax.js

Type.registerNamespace('Sys.Mvc');Sys.Mvc.$create_AjaxOptions=function(){return {};}
Sys.Mvc.InsertionMode=function(){};Sys.Mvc.InsertionMode.prototype = {replace:0,insertBefore:1,insertAfter:2}
Sys.Mvc.InsertionMode.registerEnum('Sys.Mvc.InsertionMode',false);Sys.Mvc.AjaxContext=function(request,updateTarget,loadingElement,insertionMode){this.$3=request;this.$4=updateTarget;this.$1=loadingElement;this.$0=insertionMode;}
Sys.Mvc.AjaxContext.prototype={$0:0,$1:null,$2:null,$3:null,$4:null,get_data:function(){if(this.$2){return this.$2.get_responseData();}else{return null;}},get_insertionMode:function(){return this.$0;},get_loadingElement:function(){return this.$1;},get_response:function(){return this.$2;},set_response:function(value){this.$2=value;return value;},get_request:function(){return this.$3;},get_updateTarget:function(){return this.$4;}}
Sys.Mvc.AsyncHyperlink=function(){}
Sys.Mvc.AsyncHyperlink.handleClick=function(anchor,evt,ajaxOptions){evt.preventDefault();Sys.Mvc.MvcHelpers.$1(anchor.href,'post','',anchor,ajaxOptions);}
Sys.Mvc.MvcHelpers=function(){}
Sys.Mvc.MvcHelpers.$0=function($p0){var $0=$p0.elements;var $1=new Sys.StringBuilder();var $2=$0.length;for(var $3=0;$3<$2;$3++){var $4=$0[$3];var $5=$4.name;if(!$5||!$5.length){continue;}var $6=$4.tagName.toUpperCase();if($6==='INPUT'){var $7=$4;var $8=$7.type;if(($8==='text')||($8==='password')||($8==='hidden')||((($8==='checkbox')||($8==='radio'))&&$4.checked)){$1.append(encodeURIComponent($5));$1.append('=');$1.append(encodeURIComponent($7.value));$1.append('&');}}else if($6==='SELECT'){var $9=$4;var $A=$9.options.length;for(var $B=0;$B<$A;$B++){var $C=$9.options[$B];if($C.selected){$1.append(encodeURIComponent($5));$1.append('=');$1.append(encodeURIComponent($C.value));$1.append('&');}}}else if($6==='TEXTAREA'){$1.append(encodeURIComponent($5));$1.append('=');$1.append(encodeURIComponent(($4.value)));$1.append('&');}}return $1.toString();}
Sys.Mvc.MvcHelpers.$1=function($p0,$p1,$p2,$p3,$p4){if($p4.confirm){if(!confirm($p4.confirm)){return;}}if($p4.url){$p0=$p4.url;}if($p4.httpMethod){$p1=$p4.httpMethod;}if($p2.length>0&&!$p2.endsWith('&')){$p2+='&';}$p2+='X-Requested-With=XMLHttpRequest';var $0='';if($p1.toUpperCase()==='GET'||$p1.toUpperCase()==='DELETE'){if($p0.indexOf('?')>-1){if(!$p0.endsWith('&')){$p0+='&';}$p0+=$p2;}else{$p0+='?';$p0+=$p2;}}else{$0=$p2;}var $1=new Sys.Net.WebRequest();$1.set_url($p0);$1.set_httpVerb($p1);$1.set_body($0);if($p1.toUpperCase()==='PUT'){$1.get_headers()['Content-Type']='application/x-www-form-urlencoded;';}$1.get_headers()['X-Requested-With']='XMLHttpRequest';var $2=null;if($p4.updateTargetId){$2=$get($p4.updateTargetId);}var $3=null;if($p4.loadingElementId){$3=$get($p4.loadingElementId);}var $4=new Sys.Mvc.AjaxContext($1,$2,$3,$p4.insertionMode);var $5=true;if($p4.onBegin){$5=$p4.onBegin($4)!==false;}if($3){Sys.UI.DomElement.setVisible($4.get_loadingElement(),true);}if($5){$1.add_completed(Function.createDelegate(null,function($p1_0){
Sys.Mvc.MvcHelpers.$2($1,$p4,$4);}));$1.invoke();}}
Sys.Mvc.MvcHelpers.$2=function($p0,$p1,$p2){$p2.set_response($p0.get_executor());if($p1.onComplete&&$p1.onComplete($p2)===false){return;}var $0=$p2.get_response().get_statusCode();if(($0>=200&&$0<300)||$0===304||$0===1223){if($0!==204&&$0!==304&&$0!==1223){var $1=$p2.get_response().getResponseHeader('Content-Type');if(($1)&&($1.indexOf('application/x-javascript')!==-1)){eval($p2.get_data());}else{Sys.Mvc.MvcHelpers.updateDomElement($p2.get_updateTarget(),$p2.get_insertionMode(),$p2.get_data());}}if($p1.onSuccess){$p1.onSuccess($p2);}}else{if($p1.onFailure){$p1.onFailure($p2);}}if($p2.get_loadingElement()){Sys.UI.DomElement.setVisible($p2.get_loadingElement(),false);}}
Sys.Mvc.MvcHelpers.updateDomElement=function(target,insertionMode,content){if(target){switch(insertionMode){case 0:target.innerHTML=content;break;case 1:if(content&&content.length>0){target.innerHTML=content+target.innerHTML.trimStart();}break;case 2:if(content&&content.length>0){target.innerHTML=target.innerHTML.trimEnd()+content;}break;}}}
Sys.Mvc.AsyncForm=function(){}
Sys.Mvc.AsyncForm.handleSubmit=function(form,evt,ajaxOptions){evt.preventDefault();var $0=Sys.Mvc.MvcHelpers.$0(form);Sys.Mvc.MvcHelpers.$1(form.action,form.method||'post',$0,form,ajaxOptions);}
Sys.Mvc.AjaxContext.registerClass('Sys.Mvc.AjaxContext');Sys.Mvc.AsyncHyperlink.registerClass('Sys.Mvc.AsyncHyperlink');Sys.Mvc.MvcHelpers.registerClass('Sys.Mvc.MvcHelpers');Sys.Mvc.AsyncForm.registerClass('Sys.Mvc.AsyncForm');
// ---- Do not remove this footer ----
// Generated using Script# v0.5.0.0 (http://projects.nikhilk.net)
// -----------------------------------

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Collabera
India India
Gnana (Gnanasekaran) is currently working as a Senior Architect at Collabera, Bangalore, India, having more than 10 years experience. His area of specialization includes SOA, BPM, Messaging, Integration and Enterprise Architecture. The emerging tech. trends like web 2.0 and Enterprise Mobility excites him a lot. Architectural consulting is his core expertise. He also possess experience in Data warehousing and business intelligence solutions consulting, based on the Microsoft technology stack like SSAS, SSIS and SQL Server. You can reach him via e-mails at gnana.sekaran@collabera.com & vgnanasekaran@yahoo.com or at www.gnanasekaran.com

Comments and Discussions