Showing posts with label dot net. Show all posts
Showing posts with label dot net. Show all posts

Sunday, August 21, 2016

It’s been a while, but I’m back.

When I started this blog, way back in 2008, my main goal was to record and share my experiences as I grew as a programmer.  I didn’t want to rehash the same information that you got from a hundred other sources.  Instead I wanted to show the unique parts of my eternal journey to be a better programmer.

During my three year hiatus I grew a lot, but I would put quite a bit of it under the heading of “Everyone else has been there, done that” and I could not really justify wasting your time reading such drivel.  Plus, lots of personal “stuff” happened, such as the death of my Mother-in-law and last years diagnosis of my wife’s cancer.

So, I expect to start adding new content soon.  Prepare yourself.  You have been warned.

Friday, October 14, 2011

Merging multiple DataTables from different databases in parallel

In a previous post (LINQ to the rescue!) I used linq to merge multiple DataTables, sort them and exclude duplicates.

But, what about filling those DataTables in the first place.  If, like I, you have multiple databases in production at work and need to show to the users a “database agnostic” view of their data, you need to query all those databases and merge the data.

Querying a large number of databases in serial is a slow process, but playing with threads seems … dangerous.

Well, with the new Parallel libraries, this becomes very simple to do, even with Oracle ( ;-) )

Code Snippet
  1. var dbs = new List<string>() { "Database1", "Database2", "Database3", "Database4" };
  2. var dts = new DataTable[dbs.Count];
  3.             
  4. Parallel.For(0, dbs.Count, i => LoadData(dbs[i], dts, i));
  5.  
  6. var myTable = dts[0];
  7.  
  8. for (int i = 1; i < dbs.Count; i++) myTable.Merge(dts[i]);
  9.  
  10. var dtLinqData = (from MyRow in myTable.AsEnumerable()
  11.                     orderby MyRow.Field<string>("Name") ascending
  12.                     select MyRow).Distinct().CopyToDataTable();
  13.  
  14.  
  15. static void LoadData(string db, DataTable[] dts, int index)
  16. {
  17.     DataTable returnValue = null;
  18.  
  19.     using (var connection = new OracleConnection(GenerateConnectionString(db, "MyUserId", "MyPassword")))
  20.     {
  21.         using (var dataAdapter = new OracleDataAdapter("SELECT * FROM CUSTOMER", connection))
  22.         {
  23.             returnValue = new DataTable();
  24.             dataAdapter.Fill(returnValue);
  25.         }
  26.     }
  27.  
  28.     dts[index] = returnValue;
  29. }
  30.  
  31. private static string GenerateConnectionString(string instance, string userId, string password)
  32. {
  33.     return string.Format("data source = {0}; user id = {1}; password={2}; pooling=true; Connection Lifetime=60; Max Pool Size=50", instance, userId, password);
  34. }

Wednesday, July 7, 2010

C++/cli -> calling c# dll -> calling OpenFileDialog issue

I write extensions to a Cartography program called Campaign Cartographer 3 (CC3 for short). It is sold by one of the most involved companies I have ever had the pleasure to be associated with ProFantasy.

To program an extension to CC3, you need to be able to write old school windows dlls. You remember the ones! They have a DllMain function? I saw that shudder, you do remember.

Well, whenever I can I use C++/cli (the .net version of C++) and if the extension is very complicated, I do most of my coding in C# and reference the C# dll from C++/cli. You can mix and match plain old C++ and C++/cli (and C#) through IJW (Believe it or not, that stands for "It Just Works"). As a matter of fact all my newer extensions hook into C++/cli, even if I do not use it - I want it there just in case.

Well, in my latest project, a self-contained wiki-like document reader/writer (hard to explain - maybe in a later post), I needed to call the standard .net openFileDialog and saveDileDialog controls.

All of a sudden, I'm getting COM errors!?!?

'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll

Additional information: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.


OLE calls? How old an error is that!?

Well, it seems that if you try to call the .net file dialogs from C++/cli you need to do it from a STA Thread. But, since I cannot access the main thread, remember this is someone elses application - all I have access to is my DllMain. Well, after searching around and asking about how to deal with this error on StackOverflow.com - I got my answer, sort of.

The helpful people over at StackOverflow pointed out that I needed to start my own thead as an STAThread. They also gave me advice on how to do this via COM.

Well, I'm not adverse to admit that the amount of COM knowledge I have could be held in a teacup. But the Thread advice solved the problem. I just did it the C++/cli way!

First you need to isolate the code you want to run into a class.

ref class StaClass
{
    void CallWiki()
    {
        WikiNotes::FrmWiki fw;
        fw.ShowDialog();
    }
}


Then from my main C++/cli code, I just create a new thread and call "CallWiki"

StaClass wiki = gcnew StaClass;

ThreadStart^ threadDelegate = gcnew ThreadStart(wiki, &StaClass::CallWiki);
Thread^ newThread = gcnew Thread(threadDelegate, 0);
newThread->SetApartmentState(ApartmentState::STA);
newThread->Start();


Remember though, if you want to wait until your new thread finishes, like I did, then you can:

while (!workerThread->IsAlive);
regularThread->Join();

Saturday, June 26, 2010

Fixing "Random" Default Button Behavior (asp.net)

Way back when I first started developing web applications, I quickly determined that you had to have the default button as the first submit button in the HTML markup.

A recent trouble ticket at work detailed that the default button was behaving erratically. It seemed that it was working only every other time. Yet, the location of the button never changed, so how could that be?

Here is a link of an example where I have recreated the issue.

Broken Default Button

To recreate the broken behavior, set the focus in one of the textboxes or a radiobuton and then press the enter key. The panel should minimize and a second panel should now become visible. click on the button in the upper right corner to re-expand the original panel and repeat the test.

every time both panels are visible, the default button switches to the button in the lower panel.

The fix is quite simple. Using asp.net 2.0 or higher simply add this one line to the Page_Load function: Page.Form.DefaultButton = "Button ID";

Fixed Default Button

Saturday, January 30, 2010

StrSpn & StrCSpn in C#

After converting the c/c++ string tokenizing command strtok to c#, I thought I would look around to see there were any other interesting string commands in c/c++ that had not been integrated into c#. What I found was strspn and strcspn.

strspn (String Span) Returns the length of the longest substring that begins at the start of the string and consists only of the characters found in the supplied character array.

Code Snippet



  1. private int strspn(string InputString, char[] Mask)

  2. {

  3.     int count = 0;

  4.  

  5.     foreach (var c in InputString)

  6.     {

  7.         if (!Mask.Contains(c)) break;

  8.  

  9.         count++;

  10.     }

  11.     return count;

  12. }





strcspn (String Complement Span) Returns the length of the longest substring that begins at the start of the string and contains none of the characters found in the supplied character array.

Code Snippet



  1.     private int strcspn(string InputString, char[] Mask)

  2.     {

  3.         int count = 0;

  4.  

  5.         foreach (var c in InputString)

  6.         {

  7.             if (Mask.Contains(c)) break;

  8.  

  9.             count++;

  10.         }

  11.         return count;

  12.     }

  13. }



Monday, January 25, 2010

C# TechTip #1 Using MaxLength as AutoTab

So, for all those old VB6 programmers out there: Remember The Visual Basic Programmers Journal TechTip publications.

For me, those pamphlets where the most eagerly waited part of my VBPJ publication. Here are the links to PDF versions.

VBPJ TechTips #1
VBPJ TechTips #2
VBPJ TechTips #3
VBPJ TechTips #4
VBPJ TechTips #5
VBPJ TechTips #6
VBPJ TechTips #7
VBPJ TechTips #8
VBPJ TechTips #9
VBPJ TechTips #10
VBPJ TechTips #11
VBPJ TechTips #12

I learned sooooo much from these. The loss of these publications is just one of the reasons that VSM is just a shadow of VBPJ. Just for a walk through memory lane I read through some of them, seeing if any of them would apply to C# today. Most of the tips were not transferable, but a few could be.

So, here is the first "New" C# TechTip: Originally by Karl E. Peterson

How to add an AutoTab feature to textboxes that have a set MaxLength. Connect the textboxes' TextChanged Event to this function:


Code Snippet



  1. private void textBox_TextChanged(object sender, EventArgs e)

  2. {

  3. if((sender as TextBox).MaxLength == (sender as TextBox).TextLength) SendKeys.Send("{TAB}");

  4. }





Who knew that the Dot Net designers had included the SendKeys function!?!

Sunday, January 10, 2010

Nearly Free Dot Net Books at Amazon

I eagerly await the time of arrival. Like a kid in a candy store, I make plans on what I want.

No, I'm not talking about my Birthday or another Christmas so soon. No, I'm eagerly awaiting Visual Studio 2010 and the update to C# and the Dot Net Framework. But, not for the reasons you might think.

Hard on the heals of a new Visual Studio release is a flood of new Dot Net Books that are updated for the new release. And with that, all the previous release versions are going to be marked down. If history is any indicator, marked almost to the point of being free.

If you do not believe me, search for ... say .... ASP.Net 2.0 (i.e. Visual Studio 2005) and you will find hoards of books for less that a dollar (Plus 3.99 shipping).

Soon after VS2005 arrived I purchased over $1,000 dollars of 1.1 books (Cover Price) for $107 dollars!

But Wait! Why would you want OLD info? Well, new versions add to, but does not alter the Framework, and the framework is so vast that there are always parts that we wanted to learn but didn't want to fork over the $50+ per book to learn.

So, if your like me and your on a budget and want to learn as much as you can, then after March 22nd hit Amazon and load up on VS2008 books!

Tuesday, January 5, 2010

C# Yields a better StrTok Command

Here is another use of the Yield command which allows us to create looping functions that return a value for each iteration. That is actually a great description of the StrTok command in C/C++.

The C/C++ StrTok command takes two parameters, an input string and a string of delimiting characters. After the first call to StrTok, the C/C++ programmer passes a null for the input string and StrTok returns the next Token in the original input string. Sounds like an attempt to create an Enumerable function. Unfortunately standard C/C++ does not have enumerable functions.

Here is a C# enumerable function that you allows you to iterate through the tokens found in the input string. This C# version takes two parameters as well, the input string and an array of delimiting charaters.

Then using built-in power from the .net framework we:

We split the string into a string array using the delimiting characters and we yield return each element in the string array where the element in the string arrays length is greater than 0.




Code Snippet




  1. private IEnumerable<string> StrToken(string TokenizableString, char[] Delimiters)

  2. {

  3.     foreach (var Token in TokenizableString.Split(Delimiters, StringSplitOptions.RemoveEmptyEntries))

  4.     {

  5.         yield return Token;

  6.     }

  7.  

  8.     yield break;

  9. }



Tuesday, December 15, 2009

PLINQO adds 'wow' to LINQ 'cool'

Ok, I am the first to admit that I am firmly entrenched in the "Not Built Here" camp. Not only for controls but tools as well. The only tool I've let into Visual Studio for the longest time is Resharper.

I love the power of LINQ but the LINQ to SQL ORM tools have never really thrilled me.

Well, I have changed that rule and I've added PLINQO. I've looked at other tools for ORM, even LINQ to SQL and EF. Thus far I've never liked how the code that these tools generated, but the code that PLINQO generates is the BOMB! PLINQO is like LINQ on steroids, without the roid rage!

Individual files for each table, Generated code does not overwrite custom changes, custom names .... the list just goes on and on.

I could go on and on, but there is a fantastic 70 minute video tutorial here and I guaranty that within the first 10 minutes you will want to pause the video and download PLINQO!

Monday, November 30, 2009

How to create your own Silverlight Cube Control similar to Telerik's Cube

Well, as part of our lastest project, I needed to figure a way how to spin a widget.

So, how do you rotate widgets in an Asp.Net application? Well that question is fairly simple to answer - Silverlight!

The next question is much harder: Buy or Build?

After some searches I found two controls for sale: The Telerik Cube control and the ComponentOne C1Cube control.

So, first stop, download each and put them through the paces. I found a deal breaker for each control.

We need to be able to minimize our widgets but both controls had problems with that:
- The Telerik control would resize but would apply a transform to 'Squash' the widget and according to the Telerik website FAQ, this behaviour can not be overridden.
- The Component one control 'Must' be in the shape of a cube. Ok, I know that sounds like a 'duh' point, but like I said, we need to minimize our widgets. But when I altered the height of the control to just the height of the header, the cubes' width was also adjusted.

So, that left build - but there did not seem to be any examples of how to rotate a cube from side to side, on demand. I did find an example of a continuously spinning cube. With this example to decompose, I slowly taught myself the parameters and transformations that were needed to create the appearance of a cube spinning from one face to another.

So, here is my demo of a rotating six sided cube. If you do not need to rotate to the top and the bottom, you can have sides of any height, as long as all the sides are of the same height. Plus, my example is not limited to four or six sides. This example allows for an unlimited number of sides!

Now, there a couple of things that the professional controls do that my demo cannot. My code cannot free rotate and it also does not twist as it rotates to properly show a side. If you need these properties, you may want to go with the professional controls.

Here is the Visual Studio 2008/Silverlight 3 project.

Thursday, November 12, 2009

Personal Site Launched!

Well, it has taken awhile but I've finally rolled out a personal website. LeeSaunders.net is a place that I can post about all things that interest me ... except dot net programming, of course!

There is not much content as of yet, but the reason I am posting about it here is that I've used the asp.net web template that I created in a previous post. So if you want to see a live site, not just a live example, then head out to LeeSaunders.net!

Thursday, October 22, 2009

My first free ASP.Net CSS web template

Note: I've added a label: "Free Template" for all my posts relating to converting free CSS XHML web templates to Asp.Net web projects.

While watching TV for a couple evenings, I converted a simple CSS XHTML web template into a Asp.Net 2.0 project.

The template I converted I found on ThemeBot.com. I like ThemeBot.com because most of the web templates are covered by the Creative Commons license. The license gives you two explicit rights: you are free to share the template and you are free to adapt the template. The license(s) have either one condition: you must attribute the template, in the manner as specified by the author or two: attibute and Share Alike, where if you share your creation, you must also use this license (Or a similar one).

The template I altered was this one: sparkBB014. It is a simple template for a blog. Here is the link to the sparkBB014 Demo.

Now with all the prelimaries out of the way, here is what I did:

I wanted to achive a couple of things:

1 - Use a MasterPage
2 - Wrap the reusable/optional elements in UserControls
3 - Move all the data to the code behind so that users can easily be made dynamic.

So, I created a web project and added a master page to the project. Next I copied all the markup from between the body tags and copied it into the master page.

Then I pulled out each block of data and the surrounding markup out and replaced it with a ContentPlaceHolder. Then inside the Default.aspx for each ContentPlaceHolder I placed a corresponding Content tag and filled it with the data/markup I had just removed from the Master Page.

Once that was done, I started IDing and runat=servering html elements so that I could touch them programatically.

Seeing that the entire blog design scheme was repeated for each entry, I pulled the entire structure out into into own ascx UserControl.

And since I would not want the search area on every page I moved it as well to its own ascx UserControl.

Last but not least, I removed the actual data from the markup and coded the codebehind c# to dynamically load the data into the markup. So, here is the zip file containing the project and here is a link to the asp.net site hosted at 1&1. Please, tell me what you think!

Wednesday, October 14, 2009

free asp.net web templates

Note: I've added a label: "Free Template" for all my posts relating to converting free CSS XHML web templates to Asp.Net web projects.

Ok, Why are there no websites offering free asp.net web templates? Is there no market?

There are tons of websites offering free xhtml/css website templates. Nearly all of them have licenses that allow compete freedom to alter it as long as you give credit to the creator. So, nobody can say that there is no material.

So, is it because there is no need? The way I see an asp.net web template offering is an asp.net web project with a master page with ContentPlaceHolder's sprinkled throughout so that a user of the template could get an asp.net website up and running quickly.

I'm not talking about anything as detailed as the starter kits from Microsoft, just simple templates, like the ones all over the net, but configured for asp.net.

So, tell me, would a site like ... say ... freeaspnettemplates.com be a site that anyone would use? Tell me your opinion, you just may start me on a new hobby!

Tuesday, July 28, 2009

A Checkers Rules Engine in C#

One of the things I've always wanted to program is a game using a Genetic Algorithm to generate the AI. Well at work I was talking about AI coding and my aforementioned desire came up and as we talked about it, the idea of using game of Checkers as the game I could use with a GA surfaced.

When I got home that evening and was relaxing after diner, I booted up the laptop and started cruising around the web. I was started looking around for a rules engine for checkers - hopefully in C#. You see my thought was, if I could find a rules engine that, from a given game board configuration and who's move it was, it would output all valid moves.

Well, no matter how I arranged the words in Google, I could not find a rules engine for checkers. I found a few complete C# checkers games but the rules were too integrated into the rest of the game for me to filter out.

So, I decided to write one.

I started with an enum to define the two players:
public enum PlayerColors { Black, Red }

Then I wrote a class to hold each checker piece:

CheckerPiece has a single constructor:
CheckerPiece(PlayerColors MyPlayerColor, int MyPieceLocation, bool MyIsKing)

Four properties:
public int PieceLocation { get; set; }
public bool IsKing { get; set; }
public PlayerColors PlayerColor { get; set; }
public List PossibleMoveLocations { get; set; }

and Three methods:
public char GetPlayCharacter()
public void FindAllMoves(char[] GameboardArray)
public void FindAllJumps(char[] GameboardArray)

The constructor sets the PlayerColor, PieceLocation, and IsKing.

PlayerColor defines which side the piece belongs to.
PieceLocation is an int from 0 to 63 defining each square of the game board.
IsKing is a bool that determines if the piece is a king or not.

GetPlayCharacter returns a lowercase r for a red piece, a lowercase b for a black piece, an uppercase R for a red king piece and an uppercase B for a black king piece.

a game board array is a char[64] array that can hold on of these chars 'r', 'R', 'b', 'B' or ' ' (a space).

FindAllMoves and FindAlJumps take in a GameboardArray and sets the PossibleMoveLocations list with all the possible Moves or Jumps.

Now with that built, I created the CheckersRulesEngine class.

CheckersRulesEngine has a single constructor:
public CheckersRulesEngine(char[] gameboardarray)

A static char array that holds a starting game board configuration for convenience:
static public readonly char[] StartingGameboardArray =
" b b b bb b b b b b b b r r r r r r r rr r r r ".ToCharArray();

Three properties:
public List MovablePieces { get; set; }
public List Pieces { get; set; }
public char[] GameboardArray { get; set; }

And Three Methods:
public void GetPiecesWithMoves(PlayerColors CurrentPlayer)
public void GetPiecesWithJumps(PlayerColors CurrentPlayer)
public string OutputAsciiBoard()

The constructor the GameboardArray and creates a CheckerPiece entry into Pieces for each piece defined in the GameboardArray.

GetPiecesWithMoves and GetPiecesWithJumps works its way through the Pieces collection and loads MovablePieces with the pieces that qualify.

OutputAsciiBoard is a helper function that outputs an ascii board showing the location of all the pieces.

You can get the c# code for the CheckersRulesEngine here! Or, you can download a Visual Studio 2008 solution that also includes a console program that plays a game of checkers against itself using random moves! The solution can be downloaded Here!

Tuesday, July 21, 2009

Widgets: Drag, drop and reorder. Simply done with JQUERY.

The heart of the Dropthings project, IGoogle or Pageflakes is the client side moving of the widgets. Be it dragging and dropping the widgets in other columns or reordering the widgets in a single column, this client side behaviour it the flashy part of the widget system.

In the Dropthings project the Author originally used the microsoft AJAX client side library along with quite a bit of his own code. No critisim here, he coded a complex cross-browser system that WORKED! I would not even have tried.

But, in the latest addition it says that the code was converted over to JQUERY. Well I looked at that code and while he may have converted to use JQUERY, he is not really USING JQUERY. Most of his system is still in place. No problem with that, unless you are not the Author and want to modify or enhance it.

I went another route: pure JQUERY. With just a few lines of code and a bit of AJAX to update the server I got all that functionality without all the complexity. Here it is:

        $(document).ready(function() {
$(".DropZone").sortable({
opacity: 0.5,
smooth: true,
helper: "clone",
handle: ".WidgetHeader",
connectWith: ".DropZone",
placeholder: "WidgetSortPlaceholderHighlight",
forcePlaceholderSize: true,
stop: function(event, ui) {
callMyService();
}
});
});


Thats it. You now have multi column drag and drop support. Just have your div's associated with the DropZone class and the Header of the WidgetContainer associated with the WidgetHeader class. My OnStop call to callMyService() walks through all the .DropZone controls and gets the ID of the Widget, the ID of the DropZone and the index (the order of the widgets) and calls the Webservice to update the database.

Here is a link to a working minimum example.

Thursday, July 16, 2009

A c# class to convert between bases

Ever needed to work with numbers in base 17, or base 3? I have always wanted to write a Genetic algorithm that used base 3 numbers to represent the board - 0 empty, 1 my piece, 2 opponent piece. Recently at work, we needed to work with base 36 numbers. While doing some searching I also learned that some people needed numbers that were alpha-int (Where the letters preceded the numbers) instead of the standard int-alpha.

Here is a class that I think Microsoft left out. We work different systems and different numbers every day, so why didn't Microsoft include a base converter class? It probably was just too low on their list of priorities.

Well, here is my interpretation. It is a static class that exposes three overloaded functions:
Encode(long Value, sbyte Base)
Encode(long Value, sbyte Base, bool NumeralsFirst)
Decode(string Input, sbyte Base)
Decode(string Input, sbyte Base, bool NumeralsFirst)
BetweenBases(string Value, sbyte FromBase, sbyte ToBase)
BetweenBases(string Value, sbyte FromBase, sbyte ToBase, bool NumeralsFirst)

By using the BetweenBases function, you can convert directly from one base to another without decoding to a long in between.

The complete code for the class can be downloaded here.

Saturday, July 11, 2009

Risk Map in Silverlight 2

As I mentioned in a previous post, I have reworked the USA map project to represent the map in the game of Risk.



The above image shows how the XAML is defined. The XAML is based on the SVG file found here. Once the project is ran, each country (both its inner and outer polygons) are entered into a data graph, similar to the one I used for the USA Map, with just a few improvements.

This demo, when ran, assigns each country to a player and assumes that you are the Green player. If you click on a country that is bordered with bright green, its border will turn black and all enemy held countries' borders will turn white. This shows what nations are available to attack.



If a programmer had a risk game play engine, this silverlight front-end will work quite well for you. The complete project can be downloaded here.

Tuesday, July 7, 2009

Dropthings - The good ideas and the bad

In a previous post I talked about my first impressions of the Dropthings project. Here I will talk about some of the ideas that I really liked in the Dropthings project, what ideas I will take away for my own project and the ideas that I thought were great but did not fit with my exact needs. And, at the very end I may add a few comments on another bad idea contained in the Dropthings project.

First I like the idea of not directly loading the widgets onto the page but instead having a common container where you load the widget, then the common container [lets call it the WidgetContainer :-)], is loaded on to the page. Here is a mockup of my version of the WidgetContainer user control:



The Dropthings project and my project save the widget information in two tables, the Widget table where all the default information about the widget is stored and the WidgetInstance table where the user specific widget information is stored. Since my requirements are that no controls are loaded until the user logs in, the entire generic user system in Dropthings, though cool, is not needed in my application.

So, after login, the process of loading the page is as simple as looping through the returned records and creating an instance of each widget inside its host container.

Lastly I would like to talk about the use of LINQ in the Dropthings project. Now I am not a huge advocate of LINQ, but there are times when it is the only tool that can solve the problem at hand, and I love it for that. What I do not like is that it:
A: Is database specific. Try running LINQ on Oracle or DB2 without purchasing third party plug-in. Sorry, cannot be done.
B: Unless it is watched very closely, the implementers of LINQ cross the data/rules boundary. In Dropthings you find LINQ commands everywhere. If you wanted to roll the Dropthings project out with an Oracle or DB2 back end, you would have a monumental time replacing all the Data access.

So, if the Dropthings project were not so tightly coupled with the data layer and workflow, I think (just my opinion) that the entire system would have benefited.

Monday, June 22, 2009

Creating a Widget framework in ASP.Net

Note: I've added a label: "widget" for all my posts relating to implementing a Widget framework in Asp.Net.

A recent request at my workplace sent me off looking for a Widget framework for ASP.Net similar to IGoogle and PageFlakes. All I found was Dropthings.

Just like everyone else, after downloading the source code, I loaded the project in Visual Studio and tried to run the solution. After messing with the SQL Express DB for a few minutes, the Dropthings solution fired up with no problems. Well, after playing with the example site for a few minutes I shut the site down and started it back up again, this time walking through the code, one line at a time.

After manually stepping through about a gazillion lines of code, the site finally fired up. Wow, was it really that complex to dynamically load a few widgets on a web page? OK, maybe I was so focused on the trees that I could not understand the forest. So, I tried to step through the click event of the minimize button and ... well, lets just say that there is complex and there is COMPLEX.

Before we go any farther, lets start with a few definitions:

1 - Widget: A self contained application that runs in a subsection of the web page. Widgets usually have header area similar to a windows program and just like a windows program usually have minimize and maximize buttons. Other buttons, such as refresh and edit buttons may also be available.

2 - Widget Container: One or more areas, usually columns, where widgets are displayed on the web page and with drag and drop functionality, between which widgets can be moved and re-ordered.

3 - Widget Based Site: A web site with one or more pages that dynamically display widgets that the user can personalize by adding removing and rearranging widgets.

Now, does such a framework have to be soooooo complex as dropthings? After a deep and long look at the source code, there are quite a few things to commend the author for. There is also a ton of things he needs to be castigated for.

As I endeavor to create a widget based site from scratch, I will blog my successes and failures as well as the elements I found in dropthings that I decided to recreate in my site.

Sunday, April 12, 2009

How to get AJAX to work at 1and1 (Sort of)

Normally you cannot run Microsoft's asp.net AJAX on the 1and1 servers because they have not installed it, and you cannot get it to run in a partially trusted environment.

But do not despair, older versions of Microsoft's asp.net AJAX, code named ATLAS, an still be downloaded from Microsoft.com and ATLAS does not need to be installed on the server. You only need to copy the Microsoft.Web.Atlas.dll to your bin directory.

There were two releases of ATLAS, the April CTP (community technology preview) and the June CTP. You need to download the April CTP here since it seems the June CTP needs installation.

Here is my example page on 1and1. My example uses the UpdatePanel control.