I tried to define the following:

 Public Class EvaluationCriteria
   Public DisplayText As String
   Public IsMet As Boolean = False

Hoping that I could get away with this.  Turns out, as these two values are referenced in binding via the Eval() method, these don't work correctly.  So it turns out, fields dont' necessarily work correctly with Eval.  Didn't know that until I was trying to shortcut Big Smile

Posted by bmains | with no comments
Filed under:

 As I mentioned before, AJAX supports calling web services from the client using an XmlHttpRequest object.  But sometimes, things don't go as expected.  If you make the call, an error may occur in the web service, which you'd get an error prompt.  However, there's one other aspect to this.

Sometimes the web service works fine, but you get an error with the breakpoint in the executor of the web service (ASP.NET AJAX code).  There isn't a callstack, which is really hard to debug.  What I've been finding out is that an error in the success or failed callbacks (which every web service supports a success or failed callback method that returns the results) will also act as if the executor failed, but that isn't the case.

Posted by bmains | with no comments
Filed under:

If you use web services to stream data to the client via the ASP.NET AJAX framework, you may experience challenges when you use LINQ to SQL or Entities as your data model.  This is because LINQ objects retain all of their relationships, which the serialization capabilities have trouble serializing entity sets and such.  The workaround to this is to create an anonymous type.

The anonymous type entry works well, as long as the web service method returns an object.  The anonymous type ensures that only serializable types are returned; any relationship properties can also be pushed down which makes it nice.

Posted by bmains | with no comments
Filed under: ,

I got this error when trying to view the WSDL, and to access the web service via AJAX.  The issue turned out to be easy; the type name in the ASMX file didn't match the full name of the class. I switched folders for this object, so I created it in a different folder, without changing the @WebService directive.   So Visual Studio doesn't rename the paths whenever the folders change, and thus a manual change is required in the code-behind file and the @WebService directive.

Posted by bmains | with no comments
Filed under:

I got the above error when passing data to a web service.  On the web service, a field is defined as int?.  But when I try to pass a null value, I get the above error because the value is showing up as NaN.  So it sees NaN and throws this exception.  As an alternative, I'm going to have to use a -1 instead, or convert the value to a string.

I chose the conversion to a string as the option to use as I convert the values to a string to pass in serialized form, which turned out to be the best option.  It really worked well for passing data to/from client and server.

Posted by bmains | with no comments
Filed under:

For whatever reason, an application of mine errorred on the page.Request.ApplicationPath statement.  Apparently in IIS6, this isn't working for whatever reason.  It returns null and the pathing doesn't work correctly.  The virtual pathing approach with the tilde did work correctly in this scenario.

Posted by bmains | with no comments
Filed under:

If you haven't had a chance to check it out, check out the Digsby tool:  http://www.digsby.com/?utm_campaign=new&utm_content=new&utm_medium=new&utm_source=new.  It brings your IM, social networking, and email all into one little application.  It works really well and I like it a lot.  It's a great IM tool and has a lot of great features.  If you're into facebook, you can set your facebook status right in the tool, and check all mini-feed.

In addition, you can check your gmail, msn, yahoo chat/email right in the tool as well.  Really cool.  But, if you read the EULA, it's not for work purposes (but can be installed on a work machine for personal purposes).

Posted by bmains | with no comments
Filed under:

If you get the error above, there could be a couple of reasons:

  • The XML setup in the configuration file is in error; maybe there isn't a closing tag or something syntacticly is missing.
  • If creating a custom configuration section, this could be that the entry in the <configSections> collection is missing; every custom configuration section must be registered in <configSections>.
  • The type provided is incorrect; maybe the type is in a different assembly than is stated, or the type name has a typo.

Some things to try out if you get this.

Posted by bmains | with no comments
Filed under:

You may have seen in my previous post a series of coordinates with a combination of letters to form one really long string in the PathGeometry.  This string is actually a syntax that evaluates to various Segment objects (ArcSegment, LineSegment, etc).  This is called path markup language, or has also been called path mini language.

So what do M, C, Z, etc. mean in the markup language?  You can find a guide to these options here:  http://msdn.microsoft.com/en-us/library/ms752293.aspx

Posted by bmains | with no comments
Filed under:

By now, WPF's animation is probably one of the biggest topics in the .NET community.  WPF provides so many ways to do all sorts of neat animations.  I wanted to start to discuss some of these features.  For intstance, below is an animation of an ellipse along a path.

<Window x:Class="WPFSamples.Client.Animation.Paths.PathAnimations001"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="PathAnimations001" Height="300" Width="300">
 <Window.Resources>
  <Storyboard x:Key="Storyboard1">
   <DoubleAnimationUsingPath BeginTime="00:00:00" Duration="00:00:02" Storyboard.TargetName="ellipseLocation" Storyboard.TargetProperty="X" Source="X" AutoReverse="True">
    <DoubleAnimationUsingPath.PathGeometry>
     <PathGeometry Figures="M88,56 C82,35 73,15 31,31 C5.,40 -8,52 -25,77 C-40.,101 -50.,130 -61,157 C-72,185 -74,215 -88,242"/>
    </DoubleAnimationUsingPath.PathGeometry>
   </DoubleAnimationUsingPath>
   <DoubleAnimationUsingPath BeginTime="00:00:00" Duration="00:00:02" Storyboard.TargetName="ellipseLocation" Storyboard.TargetProperty="Y" Source="Y" AutoReverse="True">
    <DoubleAnimationUsingPath.PathGeometry>
     <PathGeometry Figures="M88,56 C82,35 73,15 31,31 C5.,40 -8,52 -25,77 C-40.,101 -50.,130 -61,157 C-72,185 -74,215 -88,242"/>
    </DoubleAnimationUsingPath.PathGeometry>
   </DoubleAnimationUsingPath>
  </Storyboard>
 </Window.Resources>
 <Window.Triggers>
  <EventTrigger RoutedEvent="FrameworkElement.Loaded">
   <BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
  </EventTrigger>
 </Window.Triggers>
 <StackPanel>
  <Ellipse Width="50" Height="50" RenderTransformOrigin="0.5,0.5" x:Name="ellipse" >
   <Ellipse.RenderTransform>
    <TransformGroup>
     <TranslateTransform x:Name="ellipseLocation" X="0" Y="0"/>
    </TransformGroup>
   </Ellipse.RenderTransform>
   <Ellipse.Fill>
    <RadialGradientBrush SpreadMethod="Reflect">
     <GradientStop Color="#FFEDEDF4" Offset="0"/>
     <GradientStop Color="#FFCA2323" Offset="1"/>
     <GradientStop Color="#FFD6D37B" Offset="0.478"/>
    </RadialGradientBrush>
   </Ellipse.Fill>
  </Ellipse>
 </StackPanel>
</Window>

This markup has several key elements:

  • At the bottom of the markup is an ellipse with a RadialGradientBrush.  This brush is a nice looking brush that gives the ellipse a neat effect.
  • A storyboard object in the resources collection.  A storyboard is the "orchestrator" of sorts of the animation.  It's responsible for managing the animation timeline and performing the changes to the X and Y property of the target object (via the Storyboard.TargetName and StoryBoard.TargetProperty).

A storyboard targets a FrameworkElement object with a name.  The Ellipse has a RenderTransform attribute called TranslateTransform that's responsible for moving the object.  So values entered to the TranslateTransform move an object.  The Storyboard is going to move the object when the Loaded event is fired on the target object.

So the Storyboard uses the TranslateTransform, passing values to the X and Y properties of the TranslateTransform and consequently moving the object.  The object moves along a path provided by the PathGeometry.  I'll talk more about this later, but know that the path coordinates, along with the M, C, and other values, actually draw an arcing line that the ellipse will traverse.

When the application runs, the ellispe goes up curves around south and drops almost off of the screen.  Because the AutoReverse property is set to true, the animation reverses when it is finished, and there you have a simple animation.

Note that the path was drawn with the Expression Blend tool, and later I'll show how to draw animations with this tool.

Posted by bmains | with no comments
Filed under:

JavaScript code overall isn't that difficult to write.  It may sometimes be hard to come up with a particular task, but it isn't that hard to write.  It's hard to get syntatically correct, even with all of the features VS 2008 has to offer.  VS 2008 has a lot of nice features to help prevent this, but sometimes it's hard to see that something's missing, especially since running an ASP.NET AJAX application doesn't tell you that your script is missing a comma or period, or a variable name is wrong.

That is the difficulty as it is now with JavaScript, and it's still there in VS 2008, so be prepared as you develop with AJAX to go through your script with a fine tooth comb, looking for green squiggly lines that an error occurred (if those lines appear at all).

The sign that something's wrong with your script usually is that a component's undefined, and can't be instantiated or used.  I had this happen as a weird error occurred whenever I ran a script that my component was undefined, even though it was downloaded.  It was simply a syntax issue.

Posted by bmains | with no comments
Filed under: ,

Using JavaScript, there are two ways to create HTML dynamically.  The first is using strings:

myDiv.innerHTML = "<span>Some HTML content</span>";

THe other approach is using the Document Object Model (DOM), which has a series of methods to create HTML elements via:

var span = document.createElement("span");
span.innerHTML = "Some HTML Content";
myDiv.appendChild(span);

The createElement method creates HTML elements, which appendChild appends them to the DOM tree.  So a SPAN element is appended to a DIV.  An attribute can be set via the setAttribute method, or retrieved via the getAttribute method as well.

Posted by bmains | with no comments
Filed under:

WPF elements have several cool properties, one of with being LayoutTransform.  LayoutTransform transforms the current layout.  This can be used to do things like scaling, rotating, or skewing.  A layout transform, such as when rotating an object, rotates it at its center, but there may be some properties that modify this behavior.  For instance, when setting a RenderTransformOrigin property (used in conjunction with the RenderTransform), the LayoutTransform can be affected by this, appearing to be rotating off center.

Posted by bmains | with no comments
Filed under:

 JavaScript Event Handlers don't work the way that you may expect.  For instance, if you had a component that defined an event itemCreated.  That event could add an event handler through the "add_" method, as such:

add_itemCreated

You'd add an event handler through the process of something like this:

initialize : function() {
  this._myComponent = new myComponent();
  this._myComponent.add_itemCreated(this._itemCreatedCallback);
}

_itemCreatedCallback : function(sender, e) {
   //handler
}

This event handler would be  in the class definition of the component using the myComponent object reference.  So myComponent has an itemCreated event that gets fired by something.  When that event fires, the _itemCreatedCallback method is called.  There are a couple of ways that events can be defined though; I defined it above in a JavaScript component, but the other process can occur in the $create statement, which happens whenever the ScriptDescriptor describes the component.  The $create statement takes a collection of events by event name.  Internally, a collection of events store the name of the method to call to add the event handler, using the "add_itemCreated" method name as the key.

You may think that to reference the component you can use the this keyword in this instance; but the "this" keyword doesn't reference the component instance that has the _itemCreatedCallback; instead, the this keyword references the definition of the method, which makes it challenging because I've personally needed to be able to reference the component.  The way around that may be to pass in a reference of the component somehow as a property of the event argument associated with the event.

A better way is to create a delegate using the Function.createDelegate method.  The new approach would be:

initialize : function() {
  this._myComponent = new myComponent();
  this._itemCreatedHandler = Function.createDelegate(this, this._itemCreatedCallback);
  this._myComponent.add_itemCreated(this._itemCreatedHandler);
}

_itemCreatedCallback : function(sender, e) {
   this.works();
}

The this reference works correctly.  I can now reference the instance of the class.

Posted by bmains | with no comments
Filed under:

In JavaScript, there is a difference between object.methodName and object.methodName().  By defining the last parenthesis calls the method, where the first one refers to the methodName method instance.  So in code, if doing the following:

if (object.methodName() == undefined)

is checking for whether the returned type is undefined, where the following:

if (object.methodName == undefined)

is checking whether a method is undefined for that given type.  if trying to see if a method exists, and you specify the () at the end, an exception will occur.

Posted by bmains | with no comments
Filed under:
More Posts Next page »
The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.