Wednesday, July 25, 2007

BizTalk notes

To quick (close to useless) guide to create biz transformation solution in BizTalk Server.

Define Schema ---> Define Messages --> Map Message to Schema
--> Perform Message Transformation and operations ---> Setup your project file --> Create your snk ---> Deploy from V Studio --> Configure your project accordingly in BizTalk

*Create all your schema and messages first* Things can get easier.

Flex 2 Events

I found a great blog where you can get information on how to create Flex 2 custom events. Its better than going through pages of documentation.

Thursday, July 19, 2007

Custom Server Controls Vs Entirely Custom Controls

Sometimes you find yourself writing custom controls which uses server control provided by Microsoft.

These controls include TextBox, GridView and Button. With these control you don't have to implement IPostBackDataHandler (unless you're doing something customization) as you can wire the event shown here.

protected override void CreateChildControls()
{

base.CreateChildControls();

_txtBox = new TextBox();
this.Controls.Add(_txtBox);

_txtBox.Text = _defaultText;

System.Web.UI.WebControls.Button _txtBtn = new Button();
this.Controls.Add(_txtBtn);

_txtBtn.Click += new EventHandler(_txtBtn_Click);
_txtBtn.Text = _cmdText;

}

void _txtBtn_Click(object sender, EventArgs e)
{

////// triggerring take place here /////////

}


If you need to customized your control above to implement IPostBackDataHandler for your custom server control, then just register your component. Beware if you do that, your existing wired EVENT will no longer work.


//////////////////////// Fully Custom Server Control ////////////////////////

But when you're writing a server control whereby you have full control over the rendering of entire html codes, then you have to implement IPostBackDataHandler.

Just put these into your aspx file (registering the control):

Page.RegisterRequiresPostBack(CustomWebCtl1);
Page.RegisterRequiresRaiseEvent(CustomWebCtl1);

In your custom server code you probably have such code implementation-

public virtual bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection values)
{

string _previousValue = defaultText;
string _ctlValue = values[postDataKey];

if (string.IsNullOrEmpty(_previousValue) || !_previousValue.Equals(_ctlValue))
{
this.defaultText = _ctlValue;
return true;
}
else
{
return false;
}

}

public virtual void RaisePostDataChangedEvent()
{

WebCtlEvent e = new WebCtlEvent();
e.Text = Page.Request.Form[this.ClientID + "_input"];
OnSearching(e);

}

public virtual void OnSearching(WebCtlEvent e)
{
if (searching != null)
searching(this, e);

}

Just needed a place of put life cycle of a control for my own record......... :)

Stage 1
-----------------------------------------------------------------------------------------
CreateChildControls -----> EnsureChildControls ----> Render ----> RenderControl


Stage 2 (Recylce itself depending on how many times user click on the page)
PostBacks
-----------------------------------------------------------------------------------------
LoadPostData ---> Page_Load (check for wired events ---> RaisePostDataChangedEvent

---> RaisePostBackEvent ----> EnsureChildControls ----> force CreateChildControls

--->Render ----> RenderControls;

Wednesday, July 18, 2007

Interesting WPF Tools

Found some interesting WPF Tools

a) swfToXAML
b) MayaToXAML
c) LightWavetoXAML
d) Adobe Illustrator to XAML

Some really interesting stuff is going on.......

WebPart - UserControl Loaded Multiple Times and GridView Event not Triggerd

Creating user control declaratively in your WebPart won't give your alot of problem. But when you try to load pro grammatically a user control (ascx) into your webparts using something like this:-

Your WebPartPage

Control uc = this.LoadControl(@"webparts\CompanyNews.ascx");
uc.ID = "webPartyMan";
GenericWebPart wp2 = wp.CreateWebPart(uc);
wp.AddWebPart(wp2, LeftZone, 1);

You found that you loaded it multiple times and somethings GridView events are not triggered.
What the trick?

You only load your ascx once (you won't load it ever again) and right after you dynamically load it call SetPersonalizationDirty(); This is done using your custom WebPartManager;

This is a very simplified version of your custom webPartManager (loadPersonalizationBlob and savePersonalizationBlob)

namespace CoreWebPart
{
public class myWebPartManager : WebPartManager
{

public void SetDirty()
{
SetPersonalizationDirty();
}
}

} ///// end namespace


Then your webpart page would look something like this:-

CoreWebPart .myWebPartManager wp = (CoreWebPart .wingTipManager) CoreWebPart .myWebPartManager .GetCurrentWebPartManager(this.Page);

//// create control code to load this only once /////

Control uc = this.LoadControl(@"webparts\CompanyNews.ascx");
uc.ID = "webPartyMan";
GenericWebPart wp2 = wp.CreateWebPart(uc);
wp.AddWebPart(wp2, LeftZone, 1);
wp.SetDirty();

//// create control code to load this only once /////

Please make sure you use myWebPartManager as oppose to the standard WebPartManager in your ASPX page.