|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionThe Yahoo! User Interface Library (YUI) is a library of client-side Javascript controls that address a number of common scenarios such as calendar input, floating panels, and menus. The documentation on these controls is top-notch, so I won't spend too much time on the specifics of each control. In order to make these controls work well in an ASP.NET environment, it is a useful exercise to create custom web controls which can make it easy to drop these controls onto any ASP.NET page. Currently, the following YUI controls are supported: Using the codeFirst, you must register the tag prefix for the page you want to add the controls to: <%@ Register TagPrefix="YUI" Assembly="Web.YUI" Namespace="Web.YUI" %>
This allows you to use the YUI prefix for controls on the page. In order to use them on a page, you must have a <YUI:YahooScriptManager ID="manager" runat="server" />
Next, you can just add the controls to the page. For example, the calendar control would look like this: <YUI:Calendar id="cal" runat="server" />
Points of interest
Each control implements an interface called interface IYahooControl
{
string LoadScript { get;}
YahooScript[] ScriptDependencies { get;}
YahooStyleSheet[] StyleDependencies { get;}
}
This allows a control to specify which Javascript files it depends on, which .css files it depends on and what Javascript is needed to initialize the control. The You can control the script type (Minified, Standard, or Debug) using the <appSettings>
<add key="YahooScriptManager.HostLocation" value="Yahoo"/>
<add key="YahooScriptManager.ScriptType" value="Minified"/>
<add key="YahooScriptManager.LocalBasePath" value="/YUI/"/>
<add key="YahooScriptManager.ScriptVersion" value="2.2.2"/>
</appSettings>
In most cases, I have tried to match the object model of the YUI Javascript classes as closely as possible. There are, however, some exceptions. I decided to make some of the properties function more like most ASP.NET controls when it made sense. For example, the YUI Button control has a property called "Disabled" which defaults to false. In contrast, ASP.NET tends to use "Enabled" and defaults it to true. Most of these changes should be fairly minor. I have tried to wrap most of the panel controls into one class called ConclusionThe biggest weakness of the controls I have built so far is that they don't really provide an easy way to plug into the rich YUI eventing model. I have not yet decided on how I am going to approach this, so any feedback is definitely welcome. I have put the code up on CodePlex, so hopefully I can generate some interest and get some other developers to contribute to the project. Please check out the source code and let me know if you have any feedback. History
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||