CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jay Kimble -- The Dev Theologian

Philosophizing about the .Net religion

Atlas

  • A Night Of Ajax In Ohio (Akron-Cleveland Area) In October

    Dave Balzer (of DevAuthority fame) and I have been talking about my trips to Ohio once a month, and how I have been itching to speak (and would really love to speak in the State of my birth). 

    We need to plan far in advance so that Dave can get a place lined up.  He (not me) probably should put some kind of sign up form so we know how many to expect. 

    Do we have anything together?  Well, actually I do know what I'm going to do my talk on.  I'm going to do a somewhat informal talk which involve my into to MS Ajax, Best Practices with MS Ajax (will also apply to other Ajax libs, BTW), and my alternative to JavaScript (aka my Script#/SilverLight talk).  All in all I figure that I can talk for about 2 hours on the subjects (possibly longer with your questions).

    This will all happen mid-month in Ohio.  (to steal a variation on Jeremy's line about the ALT.NET conference). If you line in Ohio and think Ajax sux and especially MS Ajax... or if it's not TDD enough for you, come on in and give me crap.  I tick you off sometime in the past, come meet me, and find out what a jerk I REALLY am <grin />.

    Seriously, we'll be digging in to MS Ajax and you should come away with some good tools (knowledge) for assessing Ajax patterns in your development.

    BTW, stay tuned to my blog and Dave's...

  • A Day of Ajax... coming soon to Tampa...

    [I'm starting the buzz as early as I can...]

    I am in the process of putting together a free fullday training in Tampa called "A Day of Ajax" with Joe Healy (my Blog Daddy), Jim Zimmerman, and Jon Goodyear (and ASPSOFT). The presenter list has not been finalized yet (please, Joe, please get that special guest...)

    I can tell you that I am planning a killer best practices session.

    Anyway, we are planning for mid-to-late June, so watch this blog for further info.

    Technorati Tags: ,

  • Announcing the DTAjax Extensions to the MS ASP.NET 2.0 Ajax Extensions v1.0

    [oops I forgot the link I think] 

    So I tried to submit some of my controls to the AjaxControlToolbox, but was turned down... Basically when I asked if they wanted my horizontal splitter, I was asked if it complied with some composite control someone had requested (since it didn't and I didn't feel like making it work that way, I said no which ended the conversation).

    Anyway, enough about the AjaxControlToolbox, this is an announcement for my little AJax Project... so without further adieu...

    Announcing the DTAjax Extensions to the MSA2AEv1 (that would be "MS ASP.NET 2.0 Ajax Extensions v1.0")
    First of all you can get it here.  Here's what I did. I have a couple script components, a couple extensions, and a control that I wanted to release to the world. I have been building this stuff as I have been preparing to do the various trainings/presentations that I do these days (yes, you heard that right... you, too, can hire me to come give an MS Ajax training at your company.

    Script Components

    • Sys.Attribute - provides .NET style attributes to Javascript
    • Sys.Hashtable - provides a HashTable-like structure to Javascript
    • Sys.TimerUtil - provides some utilities for manipulating Server Side timer controls from Script
    • Sys.UpdatePanelHelper - provides a mechanism to register to receive events in an UpdatePanel's lifecycle

    Server Components

    • InPlaceEditExtender - utilizes the InPlaceEditBehavior sample by Nikhil Kothari from last year (I re-wrote the extender and ported the behavior to the v1 MS Ajax)
    • HoverEffectsExtender - simple Extender/Behavior for applying simple CSS hovereffects (this is mainly a sample)
    • HSplitterPanel - My many times mentioned horizontal splitter control has now seen the light of day

    Stuff to do

    • Create docs (!!)
    • Create Samples
    • Create Tests (I want good quality from this thing and tests help to be able to make sure everything is running OK... I know I'm not TDD yet, but who knows...)

    Oh yeah, the Server Components currently reference the AjaxControlToolbox (I need to doublecheck to see if it's necessary).

    BTW, I plan on making my improved ScriptManager to appear in this project and I'm open to letting others join and add their own stuff too... The idea is that this is not the big AjaxControlToolbox, but I would like it to become second to it, and would like to at least supplement it.

    Technorati Tags: , ,

  • CodeCamp Orlando slides/VS Project

    I spoke at CodeCamp Orlando on Troubleshooting Client Script apps with MS Ajax.  I wanted to publish my slides and project, so attached to this post is a zip file containing both.  The project is mainly Javascript and the aspx file.  I have actually built my own source browser so if you hit the web site from the root, you'll be able to run the sample apps (that are in VS), browse the source code, and also get the pptx file.

    There's also an Aptana directory containing the files I used for Aptana (these are the same files used with Orcas).

    BTW, people have had problems downloading stuff from this blog if they were using IE7 (I'm not sure of the exact version of Community Server we run around here or if it was just a couple people, but if you are having problems... use something other than IE7)

    Technorati Tags: , ,  

  • Orcas and Javascript: I stand corrected...

    Ok, so I complained first and asked questions later... I'm eating crow right now. Why? Because Scott Guthrie is the Man! Scott basically predicted my problem (which is a known issue)... and now I have intellisense goodness. I didn't mean to seem to be a naysayer... I just know that these CTPs are not always bullet proof.

    BTW, if you are coming to the Orlando CodeCamp this Saturday, I will be showing Orcas' Script intellisense! I think that is big enough that I won't need to give something away. Also, don't miss Dave's sessions... well, you can miss the session that competes with mine <grin />.

    Technorati Tags: , ,

  • How To: Enable Microsoft ASP.NET Ajax Extension V1.0 (and Jan. 2007 CTP) on an existing site

    This post has been moved to my new blog.
  • Thoughts on MS ASP.NET Ajax Extensions Beta and Preview CTP Beta and PageMethods...

    I have written a few posts on PageMethods (most notably here and here… there are probably a few more, but that will suffice), and have received a couple requests for help with them in the new renamed betas. 

    First of all in case you haven’t seem it, Shawne Burke has the De Facto post on them here.  Why have I pointed to his post and not made one of my own?  Well, honestly I’ve been a little busy lately, but more importantly, I’ve yet to make the things work. 

    Now the good news.  The MS Ajax team has done a great job of making them work just about everywhere, so from what I have read they now can be used in place of a service just about anywhere.

    The bad news?  Beyond the obvious issues brought up in Shawne’s post… well, check out this post over on ASP.NET forums.  Pay particular attention to Rick Strahl’s comments. 

    You see that by making PageMethods work across the board they made them too much like WebService methods and as a result there now is no real advantage to using one over the other.  I’m not sure whether this will get fixed in the next version or not (I would think that it shouldn’t be that difficult to do).  Hang on… I’m in a wait and see mode myself.

  • How To: Enable Microsoft ASP.NET Ajax Betas on an existing site

    This post has been moved to my new blog.
  • Atlas: A patch to make the AutoComplete Extender work with PageMethods (the real solution)

    [While a very cool post... this is very old.  It deals with the now defunction MS Atlas CTPs... check out the MS Ajax Extensions and the documentation (this patch is no longer needed to make this work in MS Ajax)] 

    A few months back I blogged a couple solutions to the AutoComplete Extender and PageMethods problem (here and here).  This has been a problem that has perplexed me.

    When the June CTP came out a few weeks ago I was in the throes of developing my 2 CodeCamp talks.  I tried AutoComplete again just to have it not work.  I emailed some contacts I have in the MS Atlas team to see what I was doing wrong…

    Turns out nothing.  They are slated to have this working for us, but right now it doesn’t.  I decided not to take this as the final answer.  I wanted to give my attendess and my readers a solution.  So I dug into the AutoComplete behavior (inside Javascript) to see if I could patch it. so without further adieu:

    Announcing the PageMethods AutoComplete Extender Patch!
    So here’s how it works.  I have attached the patch (in a zip file) to this message.  You need to add the patch in a script include: either a standard <script src=”… or a ScriptManager Script include (either will work).

    After that AutoComplete will now work with a PageMethods (and it should also still work with WebServices).  The only caveat is that you must mark your autocomplete methods with [WebMethod] (c#) or <WebMethod> (VB).  You will also set the servicepath to your page’s location (actually anything ending in ASPX will work fire the PageMethod in your page), and set the method to the appropriate method in your CodeBehind.

    This is my first release of this patch and I already know of some stuff that needs to change in it; feel free to let me know of any problems you find.

    kick it on DotNetKicks.com

    Technorati Tags: , , , ,

  • CodeCamp Tampa 2006... Talk summary (and code)

    [out of date post... this deals with MS Atlas CTP... which has been change drastically and is now MS Ajax Extensions]

    So I went to Code Camp Tampa this year and 2 sessions really stood out to me (probably because I had to prepare for them for about 1 month).  They were the Atlas Island Survival Kit and the PageMethods with Atlas talk.  <sarcasm>IMO, these were the 2 best talks.. probably because they were given by the best new presenter of 2006 in any CodeCamp… me</sarcasm>

    This post is mainly about giving away the code and my slides to the attendees.  I’m thinking about speaking at the Jacksonville  Code Camp next month… I had fun.

    Attached to this message you’ll find a zip file with the code and powerpoint slides.

    Technorati Tags: , , ,

  • Atlas Sample: In-Place Editing

    [Sadly this post is out of date... someday I may get around to updating it for the MS Ajax Extensions...] 

    As I’m preparing demos for my “Islands” presentation (whose concept was stolen from Don Box… I hope he doesn’t mind), I came across this old sample created by Nikhil K. from the Atlas team.  I decided to check it out (at this stage of the game I need a couple good demos, and I’m not above stealing them as long as I understand them… the problem is coming up with the concept).

    Anyway, at the end of last year/beginning of this year, Nikhil had a series of posts here, here, and here. These posts had to do with showing you how to create an extender (this is perfect for my demo).  The posts showed how to create an in-place editor which is a form that comes alive when you click on it (in FireFox and I assume Safari) and when you tab into the fields in IE. 

    This demo is really cool but it was created with the December release of Atlas (which I’m mnot sure had a Go-live license).  There were definitely some differences between the 2 client libraries that I was able to clear up quickly (NameSpaces were a little different as well as he does a direct check on IE with application object which is no longer available).

    Anyway, I updated his InPlaceEditing behavior, so that it works again with the June release (I’m sure he doesn’t have the time to go back and revisit this stuff all the time).  So attached to this message (or it will be) is an update of his project.  I’m not sure I’ll be using this code in my “Islands” demo or not, yet.

    [BTW, the only changes I made were to the namespaces (very minor change) and I changed the IE check to do a check for the existence of the onfocus event on the element... it works flawlessly in IE and FireFox]

    Technorati Tags: , ,

  • Atlas PageMethods -- expected arguments

    [out of date post... this deals with MS Atlas CTP... which has been change drastically and is now MS Ajax Extensions] 

    I was browsing the Atlas source code this evening and encountered a gem that I don’t want to forget.

    When you are calling a PageMethod (method in the ASPX codebehind) from JavaScript(documented in numerous places elsewhere in my blog), here are the additional arguments that appear after the actual method’s arguments – onMethodComplete, onMethodTimeout, onMethodError, onMethodAborted, userContext, timeoutInterval, priority, useGetMethod.

    So if you have my infamous “add” method in a codebehind page that takes 2 integers (arg1 and arg2) as arguments then the javascript add PageMethod will accept the following arguments (in this order): arg1, arg2, onMethodComplete, onMethodTimeout, onMethodError, onMethodAborted, userContext, timeoutInterval, priority, useGetMethod.

    BTW, onMethodComplete, onMethodTimeout, onMethodError, onMethodAborted are all callback functions. userContext can be very userful as it lets you specify a parameter that will arrive back to the caller that you can use to figure out what was going on in the code when this was called.  I was studying one of the behaviors (you guess which one) which simply put a copy of the current object and a string in an array and called that context.  On complete it was able to call a method on the right object (you lose context in these types of callbacks… the same is true for WebServices).

    Technorati Tags: , ,

  • CodeCamp Tampa 2006

    I’m speaking at the Tampa CodeCamp on July 15th (as you may or may not already be aware of).

    One of my demos during the PageMethods talk will involve showing you how to call AutoComplete using PageMethods.  I know I have posted here a couple posts, but I have an even better solution.  I’m working with one of the Atlas guys to see if they can show me how it works (without resorting to any hacks).  If they don’t have a solution for me by CodeCamp though, I have worked out an even better solution than what I have published before.  I is much more workable and may in fact solve a few other problems with PageMethods and Atlas.  In a nutshell I patch the AutoCompleteBehavior in Atlas’s client library, but it’s not quite that simple.  Once I’m done though I have an AutoCompleteBehavior that works with both WebServices and PageMethods.  The solution looks like it might also solve an additional problem that many folks are having with PageMethods… more on this later (Hey, this is just a tickler… if you’re in the Tampa Area around July 15th… get to CodeCamp)

    Technorati Tags: , , , , ,

  • My first Atlas behavior -- the invisibleBehavior

    [out of date post... this deals with MS Atlas CTP... which has been change drastically and is now MS Ajax Extensions]

    I have been playing with the Atlas client behaviors for some time.  [My fear is that when I finally publish my “big” post it will bomb (but that’s another matter)].  I found a reason to build my own behavior (although I may incorporate it into an Atlas client control as well)

    Here’s what I discovered.  The Atlas client side Sys.UI.Control class supports a visibility property which shows and hides an element using the visibility style.  The problem with this is that the space of the original element is always taken up on the page.  I wanted to build a collapsible panel (one that uses the display style instead).  I decided a behavior sounded like a good approach since this was new functionality not already covered in the Atlas control library (and I wasn’t building a new control… yet).

    Admittedly I started with the clickBehavior’s source code and morphed it into this:

    Sys.UI.invisibleBehavior = function() {
      Sys.UI.invisibleBehavior.initializeBase(
    this); // Initialize the base class

      var _reappearedHandler;
      var _disappearedHandler;

      this.reappeared = this.createEvent(); // Create the reappeared event
      this.disappeared = this.createEvent(); // Create the disappeared event

      // destroy this class
     
    this
    .dispose = function() {
        Sys.UI.invisibleBehavior.callBaseMethod(this, 'dispose');
      }

      // What needs to happen to start the class
     
    this
    .initialize = function() {
        Sys.UI.invisibleBehavior.callBaseMethod(this, 'initialize');
        _reappearedHandler = Function.createDelegate(this, reappearedHandler);
        _disappearedHandler = Function.createDelegate(this, disappearedHandler);
      }

      // Field that holds the value of the reappearDisplayMode property… I could have used an enum here
      //
    (the only 2 valid values are “” and “block”… this is what is used when reappear is called to set the 
      // display style to something visible)

      this
    ._ReappearDisplayMode = "";

      // set reappearDisplayMode string
      this
    .set_reappearDisplayMode = function(newDisplayMode)
      {
        this._ReappearDisplayMode = newDisplayMode;
      }

      // get reappearDisplayMode string
     
    this
    .get_reappearDisplayMode = function()
      {
        return this._ReappearDisplayMode;
      }

      // method for making the underlying element appear on the screen
     
    this
    .reappear = function() {
        this.control.element.style.display=this._ReappearDisplayMode;
        this.reappeared.invoke(this, Sys.EventArgs.Empty);
      }

      // method for making the underlying element disappear from the screen
     
    this
    .disappear = function() {
        this.control.element.style.display="none";
        this.disappeared.invoke(this, Sys.EventArgs.Empty);
      }

      // single property for determining whether the element is hidden or not
     
    this
    .get_isHidden = function() {
        return (this.control.element.style.display=="none");
      }

    /*
     
    // experimental set that was just added (untested at the time of this writing… uncomment to try)
      this.get_isHidden = function(HideMe) {
        if(HideMe)
          this.disappear();
        else
          this.reappear();    
      }
    */

      // Build the metadata
      this.getDescriptor = function() {
        var td = Sys.UI.invisibleBehavior.callBaseMethod(this, 'getDescriptor');
        td.addProperty('reappearDisplayMode', String, true);
        td.addProperty('isHidden', Boolean, false);
        td.addMethod('disappear');
        td.addMethod('reappear'); 
        td.addEvent('disappeared', true);
        td.addEvent('reappeared', true);
        return td;
      }

      // reappeared Event handler 
     
    function
    reappearedHandler() {
        this.reappeared.invoke(this, Sys.EventArgs.Empty);
      }

      // disappeared Event handler
     
    function
    disappearedHandler() {
        this.disappeared.invoke(this, Sys.EventArgs.Empty);
      }
    }
    // Set Base class
    Sys.UI.invisibleBehavior.registerSealedClass('Sys.UI.invisibleBehavior', Sys.UI.Behavior);
    // Set metadata
    Sys.TypeDescriptor.addType('script', 'invisibleBehavior', Sys.UI.invisibleBehavior);

    Now you are probably wondering how to use it.

    var myPanel;
    var invisible;

    function pageLoad()
    {
      myPanel = new Sys.UI.Control($(“SomeControl”));
      invisible = new Sys.UI.invisibleBehavior();
      myPanel.get_behaviors().add(invisible);
      invisible.initialize();
      myPanel.initialize();
    }

    function someEvent()
    {
      if(invisible.get_isHidden())
        invisible.reappear();
      else
        invisible.disappear();
    }

    [NOTE: I will try the above sample code later.. it matches exactly how I have used it in my own work.. enjoy!]

    Technorati Tags: , ,

  • An Atlas Client-Side Enhancement: Making the ASP.NET Controls easily accessible

    [out of date post... this deals with MS Atlas CTP... which has been change drastically and is now MS Ajax Extensions.. this particular post may or may not work.. your mileage will vary]

    [Small update… there were a couple issues with the code.  That’s what I get for not compiling it one last time after adding a simple parameter]

    Lately, I have been playing with the client-side of Atlas.  I have a big post on the Behaviors coming up.  Well it’s similar in the vein of the browsing the source code, except I have been building examples as I work (so I guess it will be the big behaviors post and then a bunch of examples to follow).

    Anyway, today I faced a challenge that I bet many people have faced.  That is using the Atlas client-side with ASP.NET server controls.  In case you don’t know the ID attribute of ASP.NET server controls is usually different client side.  It’s usually a combination of the control’s server-side ID plus all of its parents’ IDs with a underscore as a delimitter between all of them (it’s done probably to make sure that the ID is unique as well as to give you an object path… at least that’s my guess). 

    So the problem is that Atlas let’s you connect an Atlas class to a real HTML element if you know it’s ID.  So you don’t always know what ASP.NET will assign the client side ID to (unless either you use ClientID property from the server side or your one of the ASP.NET team).  I haven’t seen anything in the docs to suggest that the Atlas team has built anything to make it easy to get around this.  If you are building an extender or a Atlas-aware server control then you always have the ClientID field available to you, but what if you are doing something a little more basic… Atlas makes a lot of things easy, but it would be nice to be able to easily make the translation client side.

    Anyway, I decided to tackle the problem.  My solution produces a Javascript object called “ASPDotNetControls.”  This object has a method for every server side control (there’s also a switch to filter out any hidden controls that won’t be on the client); each method returns a DOM reference to that element (I chose this method so that I don’t end up with an object with references to a bunch of DOM elements).  By the way, my solution scans the entire control tree, so it will pick up all controls on the page even those buried deep inside the controls hierarchy.

    So enough of the talk here’s the code:

    protected void registerASPDotNetControlsForAtlas(bool OnlyVisibleControls)
    {
      System.Text.
    StringBuilder sb = new System.Text.StringBuilder();
     
    sb.Append("function ASPDotNetControlsClass() {\n");
      sb.Append(LoopThroughControlsForAtlasRegistration(Controls, OnlyVisibleControls));
      sb.Append(
    "}");
      sb.Append(
    "\nvar ASPDotNetControls = new ASPDotNetControlsClass();");
     
    this.ClientScript.RegisterClientScriptBlock(this.GetType(), "ASPNetControls", sb.ToString(), true);
    }

    protected string LoopThroughControlsForAtlasRegistration(ControlCollection Ctls, bool OnlyVisibleControls)
    {
      System.Text.
    StringBuilder sb = new System.Text.StringBuilder();
     
    foreach (Control Ctl in Ctls)
      {
       
    if (!OnlyVisibleControls || Ctl.Visible)
        {

         
    if (Ctl.ID != null && Ctl.ID.Trim() != "")
            sb.Append(
    " this." + Ctl.ID + " = function() { return $(\"" + Ctl.ClientID + "\")};\n");

         
    if (Ctl.Controls != null && Ctl.Controls.Count > 0)
            sb.Append(LoopThroughControlsForAtlasRegistration(Ctl.Controls, OnlyVisibleControls ));
        }
      }
      return sb.ToString();
    }

    Now all you need to do is add a call to the first method registerASPDotNetControlsForAtlas in your codebehind (I usedthe PreRender event); if you are using the UpdatePanel you might want to set the parameter to false (but be aware that you will need to check any references that you get back from the class to see if they are null).

    Here’s a quick scenario.  Let’s say I have an actual label on my form.  It might look like this:
    <asp:Label runat="server" id="MyLabel" />

    So you could turn this label into an atlas label (in javascript) like this:
    var MyAtlasLabel = new Sys.UI.Control(ASPDotNetControls.MyLabel());
    MyAtlasLabel.initialize();

    Now from the script side I can use Atlas to its fullest… enjoy…

    [A number of improvements I can think of… if I cached my script code for the complete list of controls, so that you’re not looping through the control tree on every hit… I’m too tired to come up with anymore]

    Technorati Tags: , ,

More Posts Next page »

This Blog

Syndication

News

CodeBetter.Com Home
Current Threat level
Terror Alert Level