Wednesday, February 18, 2009

I've got my Sql Server 2005 back for AclEditor.com, reconnected, and BAM! my PrezOfTheEarth data was still there!! Happy I don't have to redo that!!!

So I've added a subdomain on AclEditor.com for my old PrezOfTheEarth.com code - just to illustrate how to use AJAX, GridView, DetailsView, and many other common controls. The cool part of this is how easily (if you know how) you can do a few great things:
1) AJAXification of these controls is very standard and simple using the UpdatePanel AJAX control, and enhanceable too for a few nice tricks like the ProgressTemplate in an UpdateProgress AJAX control.
2) Using XSD for an ObjectDataSource on the page you can automajically bind, filter, sort, page and other nifty tricks.
3) Using templates, bind and eval, you can modify the representation to your taste; you don't have to accept raw data from the binding if you know how to use templates.

One other interesting trick with an infrequent side effect is using a master page to hold two "forms"... one for the "form" we care about, but another form for postback required for the google adsence HTML snippet. Sometimes however, the side effect pops up a message.

But the main point was to show how using AJAX and ASP.NET you can develop simple and codeless database-centric pages. Here the URL in the subdomain:

http://prezoftheearth.acleditor.com/

Next steps:
1) Redo this in Silverlight 2.0 to do automajic binding and a better job than AJAX.
2) Add database for the online Silverlight 2.0 version of AclEditor.com to support blobbing for file download.
3) Add code for the Silverlight 2.0 version of AclEditor.com for Save after edit.

Sunday, February 15, 2009

Silverlight 2104 Could not download


I'm trying to get my Silverlight app working on my server. I got this error: Code: 2104, Category: InitializeError, Message: Could not download the Silverlight application. Check web server settings.

First things first... using the HTML page was useful getting an error, but since it's not showing errMsg in the "errorLocation" div as I expected, I simply added
alert(errMsg);

before returning from function onSilverlightError in the header script of the generated ...TestPage.html

I saw the answer first on:
essentially adding Silverlight support to IIS - mime types .XAP and .XAML plus "Enable Content Expiration" to 1 min plus "Execute Permissions" to Script only.
I went to my ServerSea.com control panel and added mime types for .XAP and .XAML and now my Silverlight 2 replication process for AclEditor is in process and working. I've still got to complete the save part of it... download is a challenge for Silverlight but doable in a number of ways. The site is: http://www.acleditor.com/AclEditorSilverlight.aspx
Now it's time to get my entire site up and ready for prime time.
I've got interviews all this week as I finished my Sivlerlight 2 contract Friday with Optimal Interiors - CAD in the Cloud over the Internet for instant room layout, using Silverlight for no-postback client-side intelligence. Too cool ....
Anyhow I've got to get my sites all running optimally here in the next few days.
But acleditor.com is _ALMOST_ 1/2 way ready.

Saturday, February 14, 2009

Live, Jumping into

There is so much to do so little time. In my time off, since I'm between contracts as of yesterday, I'm diving into the Live framework...
Forum:
http://social.msdn.microsoft.com/Forums/en-US/liveframework/threads

main site:
http://dev.live.com/

I've got a simple example:
http://www.acleditor.com/MAPLIVE.ASPX

Fun stuff.

Dan

Friday, February 6, 2009

Blue Gradient in XAML

I'll show a custom color gradient in XAML.
Note that it's slightly different declaration and usage in Silverlight 2.0 and in WPF (or Windows Presentation Foundation) 3.5 SP1.

Here is the XAML in Silverlight (Page.xaml):
< UserControl.Resources>
< LinearGradientBrush x:Key="LightBlue4Background" EndPoint="0.5,1" StartPoint="0.5,0">
< GradientStop Color="#FF6C83D8" Offset="0"/>
< GradientStop Color="#FFEDEFF6" Offset="0.25"/>
< GradientStop Color="#FFA4AED6" Offset="0.75"/>
< GradientStop Color="#FF0B3EFF" Offset="1"/>
< /LinearGradientBrush>
< /UserControl.Resources>

Here's how to use it in Silverlight 2.0:
< Canvas x:Name="uxcLayoutRoot" Background="{StaticResource LightBlue4Background}">
< TextBox x:Name="uxtDid" Background="{StaticResource LightBlue4Background}"/>
< /Canvas>

Here is the XAML in WPF 3.5 SP1 (MyAppName.xaml):
< Window.Resources>
< LinearGradientBrush x:Key="LightBlue4Background" EndPoint="0.5,1" StartPoint="0.5,0">
< GradientStop Color="#FF6C83D8" Offset="0"/>
< GradientStop Color="#FFEDEFF6" Offset="0.25"/>
< GradientStop Color="#FFA4AED6" Offset="0.75"/>
< GradientStop Color="#FF0B3EFF" Offset="1"/>
< /LinearGradientBrush>
< /Window.Resources>

Here's how to use it in WPF 3.5 SP1:
< Canvas x:Name="uxcLayoutRoot" Background="{DynamicResource LightBlue4Background}">
< TextBox x:Name="uxtDid" Background="{DynamicResource LightBlue4Background}"/>
< /Canvas>

I notice the difference in StaticResource vs DynamicResource.
Checking back, it doesn't seem to make a difference in WPF.

Dan

Thursday, February 5, 2009

event like property plus safely CallEventHandlers

I'm showing how to define events similarly to how as you define properties... a best practice.
I'm showing how to call these event handlers in a safe way to handle exceptions... another best practice.

I've defined two events, one for save and and one for complete using the "event" keyword instead of the "property". The type is of EventHandler which has "add" and "remove" operators += and -=.

Each event has an "add" and "remove" like a property has "get" and "set".
Each event is different in another way to, using += and -= to add/remove a callback to the respective EventHandler.

Here are the events:
private event EventHandler m_Complete;
///
/// Event occurs on complete.
///

public event EventHandler Complete
{
add
{
m_Complete += value;
}
remove
{
m_Complete -= value;
}
}

private event EventHandler m_Save;
///
/// Event occurs on save.
///

public event EventHandler Save
{
add
{
m_Save += value;
}
remove
{
m_Save -= value;
}
}

The code to call the event handler has to first check to assure there IS an event handler (not null). In the for loop iterating over the individual handlers registered in the respective event "add"... the code has to catch exceptions that any of the individual handlers throws so the remaining handlers will get called.

Here is the "safe" code:

///
/// Calls the event handlers.
///

/// The save or complete event handler.
private void CallEventHandlers(EventHandler saveOrComplete)
{
// assure event exists
if (saveOrComplete != null)
{
// loop event handlers and call em'
foreach (EventHandler eh in saveOrComplete.GetInvocationList())
{
try
{
// try to call the event handler
eh(this, EventArgs.Empty);
}
catch (Exception ex)
{
string s = ex.Message;
}
}
}
}