Share on Twitter

An Example Of The Need To Use Absolute URLs

I have been doing some work around twitter and ASP.NET MVC. The way twitter authentication works, is that I have a page that creates a twitter URL, redirects the user to twitter, imagethe users accepts to use the application associated with the website, and twitter redirects the user to a callback URL, the completes processing of the user credentials. In order to set a callback URL dynamically (especially in development, when the callback is likely a localhost one), we need to send the absolute URL to twitter.

Other examples might include having a “permanent URL” for some resource (product, blog post, etc..), or maybe a link to be used in emails or so. There can be many usages, so, let’s see how to do it!

How We Did It In Webforms

In webforms, the easiest way to do it was to use the Control.ResolveClientUrl() method.

Typically you pass a URL relative to the current code file (.aspx, .master or .ascx file). and it returns the corresponding absolute URL of that. Of course when the file is a control or a master page file, we don’t always want/have a path relative to this file. The work around for this was passing a relative URL that starts with “~/”. As you probably know, “~/” represents the root of the website.

, , ,
Share on Twitter

the AjaxControlToolkit has a new release, the release includes bug fixes and new HTMLEditor, ComboBox, ColorPicker controls/extenders.

HTML Editor

I liked the HTMLEditor control so much from first sight. Pretty lightweight and customizable. I still need to check whether it works fine inside UpdatePanel and whether it can be used with RequiredFieldValidator or so.

image  image

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/HTMLEditor/HTMLEditor.aspx

 

Color Picker

The ColorPicjker is just an extender to TextBox control. This means a lot of opportunities and promises less problems with validators, etc… It’s a very nice one too.

image

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ColorPicker/ColorPicker.aspx

 

Combo Box

The ComboBox is a control that is like a DropDownList with auto complete except that the user can enter a new text that is NOT in the existing items. This is good or bad based on your sole use.

I did not like how it’s not well styled in the example page. This means it’s going to be headache to style in my sites as well, which is one of the biggest problems with AJAXToolkit in general.

image

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ComboBox/ComboBox.aspx

 

 

Share on Twitter
, , , , , ,
Share on Twitter

This is problematic with ASP.NET AJAX. The main Script Components are NOT sent to the client when in :Legacy” mode. This is “By design” in ASP.NET AJAX, although it is a clear limitation!!

I’m investigating the problem for other solutions and will be sending an update soon.

Thank you, Iman Halawany, for making me note this. I’ve been working on WCF services and ASP.NET MVC stuff lately than normal webforms, so, didn’t realize this obvious showstopper.

To all my readers, I owe you a BIG apology.

The Problem

ASP.NET validators and ValidationSummary controls are rendered as SPAN tags that are shown and hidden based on validation state. The properties of the validators are written normally via JavaScript calls similar to these:


<script type=“text/javascript”>

//<![CDATA[

var Page_ValidationSummaries =  new Array(document.getElementById("vdsSiteLogin"));

, ,
Share on Twitter

If you have ever thought that the famous if(Page_ClientValidate("validationGroup")) {/*JS Code*/}  and myValidator.ValidationGroup = "validationGroup"; are sure not enough client side capabilities in ASP.NET validators, you are right.

The list of client side API for ASP.NET Validators can be found on this MSDN page "ASP.NET Validation in Depth":

http://msdn.microsoft.com/en-us/library/aa479045.aspx#aspplusvalid_properties

Look for subtitle: "Client-Side APIs".

 

Thanks Simone Chiaretta for mentioning the topic, Mohamed Tayseer for sharing the topic on facebook, and Richard Cook for his comment on the post making me search for the complete list.

Share on Twitter
, ,
Share on Twitter

With MIX, and meeting the announced MVC roadmap, the new versions of AS.NET Extensions are now publicly available.ASP.NET MVC Framework Preview 2 is available also as separate download, same as Silverlight 2.0 BETA 1 (and Expression studio, Silverlight VS 2008 Tools).

Download Links:

Additional Resources:

  • Announcements
  •  

    Have fun :)

    Share on Twitter
    , , , , , , , ,