Tales from the Evil Empire

Bertrand Le Roy's blog

News


Bertrand Le Roy


Add to Technorati Favorites Tales from the Evil Empire - Blogged

Blogs I read

My other stuff

Archives

Some Atlas feedback

Karl wrote some feedback about the eWeek article:

"What's the perception from the ASP.NET team on how interested the developer community is in Atlas? Personally, I’m extremely apathetic about the technology and the hype around it. Since the day Atlas was announced, it’s always seemed like an un-innovative attempt to catch-up. Of course, there’s still plenty of confusion about what Atlas is and why you’d want to use it versus client callback (man, is that still around?) and other 3rd party AJAX providers (Ajax.NET, MagicAjax, …). I played with the PDC bits, and was thoroughly put off by the declarative programming samples – it burdens the development process and seems like an “oh isn’t this cool” when it really doesn’t have anything to do with the problem space being solved.

You and I talked at TechEd. I was writing the AJAX.NET documentation and wanted to bounce some ideas off you about client-callback and ajax.. At that point,
Atlas wasn’t publicly known (not sure if it was internally known, since client-callback was still the in-thing). Frankly, the ASP.NET team seemed totally disconnected about the topic, and to this day continues to go down an unclear path.

On July 14th you had a wonderful post titled “Some thoughts about server callbacks and Ajax.NET”, in which you identified a possible alignment issue between the
ASP.NET team and average developers. To me that should have sent a red flag to Scott and crew, but I’ve never really seen the topic followed up. If you guys think of things one way, but “most users” think differently, then there’s a problem. What checks have been introduced since callbacks to make sure Atlas is better aligned?

To be fair, my exposure to
Atlas hasn’t been great. The problem is, I’m not really sure why I need to bother with it. I just don’t see what added-value Atlas will bring to my already-rich XmlHttp toolset. I realize that part of Atlas is another prototype (prototype.conio.net), and that’s great (assuming I don’t want to use prototype for some reason).

About the article, parts of it deserve to get slashdotted and ridiculed. JavaScript isn’t OO? No exception handling? No inheritance? Googling any of these terms “javascript object oriented”, “javascript exception handling” and “javascript inheritance” results in a number of useful hits. There are other quote-worthy things in that article."

Karl, what interesting feedback that is. I'll forward it to the team.
First, I think you're mistaking me for somebody else as I've never been to TechEd. Maybe we can meet at the Mix conference in Las Vegas if you're going? Otherwise I'm sure we'll have the occasion.
Enable me to disagree forcefully on Atlas being uninnovative. I think it's well ahead of any other existing AJAX toolkit on almost all accounts and it's not even beta.
First, let's talk about the declarative syntax (although it seems like I've had this conversation a million times already but that's fine). Some people don't like declarative languages. We know. It's the same with ASP.NET, and it's the same with XAML. Most people love it, some just hate it. Four things need to be pointed out:

  • xml script is not mandatory. It's just a way to instantiate classes and set properties. If you prefer to do that programmatically, sure, go ahead (same goes for ASP.NET and XAML).
  • Despite critics arguing that declarative syntax is more verbose, just try writing the same code programmatically and count the chars...
  • Declarative code is way easier to handle for a designer. Today you author xml-script by hand, tomorrow designer integration will help you do it in a way no programmatic approach can enable.
  • You may have noticed that client-side Atlas components are significantly smaller pieces of logic than the typical server control. That's because we're currently creating the building blocks for larger logical units like server controls or composite client controls. That explains why for the moment it feels like Atlas forces you to assemble a lot of different little pieces to get a simple thing done. That will definitely change.

But it certainly isn't something that we're forcing down the throat of our users because we think it's "cool". We're doing this because we think it's the right approach and one that's already worked in the past. Better, we've learned from mistakes of ASP.NET and try to improve on that.

Now about this other post on callbacks. The problem I was talking about was that ASP.NET callbacks were aimed at control developers whereas the main demand for Ajax technology was from page developers. These are two very different parts of our audience (even though some people may belong to both). Control developers are usually more willing to delve into technical details, whereas page developers are more results-oriented. ASP.NET callbacks are clearly wrong for page developers. The reason for that is easy to understand: callbacks were created for the team to develop its own ASP.NET 2.0 controls. As for much of what we're doing, we've exposed this API publicly so that other control developers can leverage it, but it wasn't a very universal feature.

That was the main motivation behind my developing the RefreshPanel, an easy way to leverage callbacks for page developers. This component and sample library has been pretty successful despite being only advertised from my blog, and it's been one of the main sources of inspiration for Atlas' UpdatePanel. This is really an area where I think we have listened to community feedback and have acted on it. The first feedback we've had on UpdatePanel is overwhelmingly positive because it's so easy, works well and is completely unobtrusive.

I think we're also going well beyond prototype (which is a framework we have a lot of respect for). The object-oriented work in Atlas is just the foundation for the component and control infrastructure. What other AJAX client framework has live data, templated controls, true separation of layout and logic, excellent integration with the server and good designability?

Let me get something straight about the eWeek article: you're absolutely right when you point out some inaccuracies and of course I had the same reaction when I read it. It's an interview of a consultant by a journalist. There has to be some distortion if you see what I mean, and I personally don't think it's a big deal. True, JavaScript is a lean and smart language, and it's certainly not the toy most think it is (though my preference in dynamic languages would probably go to Python). It does kind of have OO capabilities (in an non-intuitive and almost hacky way). It does absolutely have exception handling (even though that is limited in many ways). So the article is wrong on a few things. I don't think it makes it worthless. It's certainly not a technical article, it's aimed at a more executive public. It sure is nice to us :)

Finally, to answer your first question, we're getting a lot of positive feedback on Atlas, and the community is actively discovering the technology even though it's still pre-beta. See for yourself the activity in the Atlas forums:
http://forums.asp.net/default.aspx?GroupID=34

But any feedback is useful to us so keep it coming.

Thanks,
Bertrand

Comments

foobar said:

Atlas is one of the most glorious things to come out of the ASP.NET dev team.

It's simplicity is simply amazing. There's so much tedium saved when using the paradigm provided by Atlas. The lone fact that code-behind usually never needs to be touched is a testament to how encapsulated Atlas is.

Compared to all of the other solutions I've seen, Atlas is the most feature complete and definitely the least intrusive in terms of modifying existing code.

Keep up the good work.
# February 2, 2006 5:01 PM

scottgu said:

Here is a sample of using the <atlas:updatepanel> control with the December CTP to build a Task-List application that is Ajax based and enables paging, sorting, in-place editing and RSS feeds in ~40 lines of server code and 0 lines of client-javascript: http://weblogs.asp.net/scottgu/archive/2005/12/26/433997.aspx

You can download it and play with it locally if you have either VS 2005 or Visual Web Developer installed.

Hope this helps,

Scott
# February 2, 2006 5:22 PM

blowmage said:

What really frustrates me about the Atlas libraries right now is that it seems to be very difficult to do what is so easy in other libraries. I guess I'm speaking specifically of behaviors. I want to drag an item, any item, (not necessarily a list item - it could be any element) and when I drop it I want it to *revert* to its previous location.

And then I want to know if it was dropped on an element I care about so I can handle that event.

Here is the code from the "drag-and-drop" section on the script.aculo.us web site (http://script.aculo.us/):

<img id="product_1" class="products" src="images/product-1" alt="mug">
<img id="product_2" class="products" src="images/product-2" alt="t-shirt">
<div id="shopping_cart" class="cart">
<img src="images/drag-here" alt="">
<div id="shopping_cart_text">Drag all the stuff you ever want right here.</div>
</div>

<script type="text/javascript" language="javascript" charset="utf-8">
new Draggable('product_1',{revert:true});
new Draggable('product_2',{revert:true});
Droppables.add('shopping_cart', {
accept: 'products',
hoverclass: 'drophover',
onDrop: function(element) {
$('shopping_cart_text').innerHTML =
'Dropped the ' + element.alt + ' on me.'; }});
</script>

I wouldn't mind writing the script code declaratively, but I don't want to write my own controls implementing IDragSource and IDropTarget to do this either. I just want to wire it up and have it work. So right now it seems Atlas is solving problems I don't have, and makes it difficult to solve problems I do have.
# February 2, 2006 5:29 PM

Bertrand Le Roy said:

Blowmage: I don't know the Atlas drag & drop feature too well so I can't provide you with a solution from the top of my head but I'll ask around.
Maybe you can tell me exactly what your scenario is and what you feel is missing. From what I know we can handle html elements (like your sample is doing) or arbitrary data so I doubt this sample could not be reproduced with Atlas.
I'll get back to you when I have an answer.
# February 2, 2006 5:41 PM

blowmage said:

Thanks Bertrand. I also don't doubt that Atlas can't deliver the same result, but the question is how? And how much effort is involved? I investigated the November release for quite a while, and the "right way" to use Atlas seemed to be to write new IDragSource and IDropTarget controls to achieve the desired result. I found this to be too much effort for (rapidly changing?) pre-beta scripts and went with the solution I've already written using prototype/script.aculo.us.

If you, or anyone else, could show an Atlas version of the previous code snippet that delivers the same result I will gladly dump prototype/script.aculo.us in favor of Atlas for the project I'm working on.
# February 2, 2006 6:08 PM

Wilco Bauwer said:

Blogmage: you should be able to do something similar already using Atlas. In fact, Scott Guthrie did something similar in his keynote demo at PDC05 (declaratively).

Anyway, I believe the DND API in Atlas is flexible enough to allow for all sorts of scenarios - from floating elements to drag/drop between zones to drag/drop between external applications (IE-only). However, the current behaviors that use these API's don't integrate that well with the other controls which makes it a bit difficult to do anything useful with it.
# February 2, 2006 6:08 PM

Bertrand Le Roy said:

You know, that's exactly the kind of feedback we need. If a feature is not covering your most common scenario except by having you jump through loops we want to know and we'll make that better.
I'll definitely follow-up on that and either post an equivalent sample or make sure this is addressed in a future release.
# February 2, 2006 6:11 PM

Graham Dyson said:

Personally when I installed the first versions of Atlas, had a quick look and couldn't see how I would ever make productive use them. But from reading this blog and being a page and control developer myself I took them for what they were, a prototype.

The newer stuff is fantastic and is coming from a much better angle. The openess of how your developing it is giving it a user focused direction. I can see how I'd use them directly in alot of the web applications I'm working on and give massive benefits to my users expriences.

Keep up the good work lads!
# February 3, 2006 7:28 AM

Lukas Peyer said:

As far as i know there is no drop event in Atlas DnD by now, but promised for the next release. So we have to be patient until we can use simple declarative Drag n' Drop within Atlas.
Definitively looking forward to that too.
# February 3, 2006 12:35 PM

karl said:

Damnit, burnt on the first point :) I was sure it was you, oh well.

I never said I was right (well, except for the declarative part ;) ), but I did think my perception might be shared by others. I haven't given Atlas a fair chance, and that's part of what bothers me - normally I'm an early adopter and excited about this kinda stuff, but somehow Atlas hasn't managed to float my boat as it were.

When I get some spare time, I _will_ take a thorough look of Atlas and hopefully use my skillz to help others see the light I'll hopefully find :)

Cheers,
Karl
# February 3, 2006 12:38 PM

Steve said:

I have a sample:

Today, I needed to validate that a value was entered into a textbox if a radiobutton list item was selected in a radiobutton list. I explored the validation controls but they didn't help me much since the customvalidate accepts just a client side function name, without parameters.

I first off had to have the client side code in a .js file for easy debugging.

But ASP.NET gives control id's - so I had troubles using javascript 'getElementById'. Since I couldn't pass the clientid to the customvalidator I got stuck.

The whole time I was working on this issue, I thought 'I wish Atlas could solve this because I really don't like generating javascript code'

# February 4, 2006 12:41 AM

Bertrand Le Roy said:

Steve: I'm not sure what you're trying to do here. Are you using ASP.NET validators or Atlas validators?
You can get the client id from the server control by looking at its ClientID property.
# February 4, 2006 12:53 AM

Bob Campbell said:

In all fairness to the consultant/journalist, Eweek and Karl, part of what is being discussed here comes directly form the "Understanding AJAX Applications and ASP.NET 'Atlas'" document that is part of the Atlas Hands-On Lab vsi. The document states under the AJAX Technical Concepts section "...Furthermore, because JavaScript is not an object-oriented programming (OOP) language, it does not have strong typing, namespaces, exception handling, and other OOP features." Note: the hands on lab is great.

Bob
# February 4, 2006 10:18 AM

Steve said:

ASP.NET creates its own id at runtime - that is some of my problem.

I haven't tried the Altas validators yet - I will give them a go.

Thanks!

Guess my overall question is - will Atlas satisfy my client side needs or is it just about 'ajax' ?

I'm a huge fan of C# - not a big fan of javascript - but I love the results of good client side code
# February 4, 2006 6:42 PM

Bertrand Le Roy said:

Bob: that's a good point. The hands on lab document is wrong too, then.

Steve: I'm still not sure I understand the problem here. Did you try using ClientID? Yes, Atlas is much more than just Ajax: it's a complete client-side framework and not just a communication infrastructure.
# February 4, 2006 8:13 PM

Steve said:

ClientID?

Yes, in my .js file I try to get the id - but the ID is not the Id of the control as I put in the page.

ie.

I get some ctl01_<name of control>

This 'ctl01' is not my id and there is no way to know that id from my .js file.

I don't put script in my pages since I can't easily debug my scripts.

Also - I can't pass the id when I use a customvalidator - there is no place for parameters, all you can you do is specify the client side function.

How do I under how this new framework works for javascript? All I've seen is typical javascript with calls to web services with JSON.
# February 4, 2006 11:24 PM

Bertrand Le Roy said:

As I've said before, you can get the client Id server-side using ClientID, but you don't even need to do that. The client-side custom validation function has a signature that enables you to get a reference to the element and arguments: function(sender, args). The arguments have a Value property and an IsValid property. Please read that article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIWebControlsCustomValidatorClassTopic.asp
# February 6, 2006 2:09 AM

Steve said:

Betrand, I'm sorry but you can't get the clientid in your javascript, it's dynamically created at runtime.

Maybe your misunderstanding my post, but everyone knows this issue where ASP.NET generates id's at runtime that are not the same as the id you set, especially when the control is 'inside' another structure.

As far as the validator, it only gives you the control itself, but if you want to check the value of a different control to against that control , you can't pass get a handle on it. The only reason again that I would want to do this is because you can't access the generated clientid.

I know the <%= control.clientid %> - but this does not work unless you put the javascript in the aspx page, which I don't - it's in a separate .js file.

Again, I don't want the client id on the server side, I want the id of the control in the javascript code.

ie. I have a radiobuttonlist and a textbox. Based on whether a valid is selected in the radiobuttonlist determines if the textbox is required. ie. selected value 3 in the radiobuttonlist requires text in textbox. Therefore, my validator needs to know both the radiobuttonlist clientid and the textbox clientid in the javascript. But, instead of id's of 'TextBox1' and 'RadioList1' it's something like 'ctr01_TextBox1' and 'ctr02_RadioList1". (This really poses an issue if you add a new control because it can change this dynamic id).

Surely you understand this?

# February 6, 2006 8:28 PM

Steve said:

Here is another issue - when you use anything in ContentPlaceHolder:

it doesn't use the id of, ie' TextBox1 - it uses ctl00$ContentPlaceHolder1$TextBox1 as the client id - which you would have to use this second name in the .js file and hope it doesn't change.

I'm encountering this with the previouspage cross post:

TextBox txtName = PreviousPage.FindControl("txtName") as TextBox;
TextBox txtName2 = PreviousPage.FindControl("ctl00$ContentPlaceHolder1$txtName") as TextBox;


The first one above doesn't work - I have to use the ASP.NET generated id instead.
# February 7, 2006 11:57 AM

Steve said:

I have discovered the problem:

Master pages.

When I use regular pages, the clientid's work fine.

When I use master pages - ie. a cross page post it changes or rather creates it's own id.

TextBox txtName = PreviousPage.FindControl("txtName") as TextBox;
TextBox txtName2 = PreviousPage.FindControl("ctl00$ContentPlaceHolder1$txtName") as TextBox;

The top example fails, the second works with a master page.
# February 7, 2006 12:24 PM

Bertrand Le Roy said:

Steve: Server-side, when you want to use FindControl to find controls that are in any kind of naming container, don't call Page.FindControl, use the container's version of FindControl. So in your second scenario, you'd get the master page from the previous page and then find the control from there. Same thing for a panel or any container control.
For your validator control, the way most people do this is by creating their own validator class and adding it a property for the second control's id. At pre-render time, the new validator control will have to register a startup script that initializes a small javascript structure that the validator's js file can find from its own id and then lookup.
To be clearer, the validator generates something like ClientID + "_secondControlID = \"" + FindControl(SecondControlID).ClientID + "\";"
The validator script evals its own id + "_secondControlID", and the result is your second control's client id, which can then be obtained using getElementById.
The FindControl here may be replaced with something that looks up the naming container chain so that it works inside repeaters and other containers.

But here's something I'd like to ask you: this is completely off topic and is polluting the comments thread. Furthermore, I see that you've posted similar questions on Nikhil's blog on a post where it is equally off-topic. Next time, please contact me directly through the contact page of this blog or ask your question on the relevant forum on http://www.asp.net.
# February 7, 2006 1:30 PM

Steve said:

The issue was concentrated around this topic and did get off topic, my apologies.

The main question and details I was looking for was about this:

"Yes, Atlas is much more than just Ajax: it's a complete client-side framework and not just a communication infrastructure. "

My example was really about the integration between writing javascript and accessing the controls on a page. It's in this whole setup that I would like to learn more about how Atlas will help on this.

My example was sideswiped by conversations on 'clientid' when actually that is the point of my question: it's these type constructs when working in javascript that I hope Atlas addresses.

I'd like to see more talk and conversation about this client-side framework and less about the communication infrastructure. I think the closest I've seen is on Nikhil's talk on behaviors. It seems more oriented toward 'control developers' than page developers.

This is not a complex sample, but I was working with the ASP.NET Menu control yesterday and I noticed that when you select a menu item that the page does a postback. The page also has a submit button. I'd like to be able to have the menu not do a postback but still be able to pass me the selected value before submitting. Unlike last time with validators, don't get caught up in the details - because what I'm asking is - will Atlas be the approach to take for this type of senario? Or do I need to, ie, attach attributes to the menu items and store values in hidden fields?

I'd like for Altas to make it a rich experience in the UI without all the javascript - mostly because I'm more of a C# developer who is asked many times to provide a richer interface that requires javascript. With Atlas I see a solution.

Again, sorry to go off topic, but I think it's really on topic because it shows the 'work arounds' required to do something as simple as accessing a control id through a DOM.
# February 8, 2006 7:37 AM

Bertrand Le Roy said:

Steve: Sure, I see your point here. Typically, an Atlas aware server-side control will generate xml-script instead of all the JavaScript that's needed today, like in your validator example, which should be much cleaner. But in essence, the solution is not that different: you have a js file that contains the definition of your client-side behaviors, html and something that glues the two together. In ASP.NET 2.0 you had ad-hoc JS functions in the js file, and javascript code to do the glue. In Atlas, you'll have classes in the js file and xml-script to glue. It will be much easier to generate the glue from the server-side than when you had to come up with hacky JS like I described in my last comment.
I'll try to write more posts on the client-side framework as it can be used by page developers.
For the menu control, you can already prevent the postback by using NavigateUrl with the javascript: protocol. It's not an ideal solution but it gets the job done and it's fairly simple. An Atlas Menu control would be best here, but we don't have that yet.
C# developers who want a richer web experience without the JS are a primary audience for us. Rest assured that will show in the final designs for Atlas.
(and I think we're back on topic now, thanks).
# February 8, 2006 1:28 PM

Maestro said:

I would like to see better javscript library support for those of us who are willing to brave the big bad world of javascript. (perhaps even explore the use of prototypes for code organization??? the current javascript code looks aesthetically like shit, as I'm sure you know) Also I would like to see JSON added to Atlas (or something JSON-like) utilizing full .NET attribute support etc. Also there are some timing bugs in the XMLHTTP wrapper code that occasionally delay the execution of synchronous calls till after queued asynchronous calls instead of right away. Give us lightweight optional tools like JSON, not heavyhanded all-encompassing "solutions". Otherwise, looks good.
# February 20, 2006 6:47 PM

Bertrand Le Roy said:

Maestro, we ARE providing better OO support for JavaScript (namespaces, interfaces, enumerations, etc.) and we ARE using JSON on the wire (there are JSON.serialize and deserialize methods client and server side) so I'm not sure what you're referring to.
Also, the bug you're talking about seems to be coming from most browsers only allowing for 2 simultaneous connections to the same domain but it could also be the batching code that we have in place that will become optional in future releases. But without more details, it's hard to tell.
# February 20, 2006 6:53 PM