Sunday, March 11, 2012

Common location for Always Visible Control Properties

This solution applies to the former Community Technology Preview (CTP). Procedures to modify and implement the same changes in the new AJAX Beta 1.0 might vary some. I made changes in one place that applied to all my pages.

In Visual 2005 C#, in AtlasControlToolkit.AlwaysVisibleControlBehavior.js modify zero values to values you want (e,g., 34)

// Custom property indicating the desired
// offset from the horizontal edge of the window
var _horizontalOffset = 34;

// Custom property indicating the desired
// offset from the vertical edge of the window
var _verticalOffset = 34;

Then, "Build" AtlasControlToolkit. Results in an AtlasControlToolkit.dll being generated. Close VS C#.
Open VWD 2005. Copy AtlasControlToolkit.dll to your project's bin; replacing current AtlasControlToolkit.dll.

In each page, remove parameteric offset values so the code ends-up looking like this (enabling the AtlasControlToolkit object to drive offsets) :

<atlasToolkit:AlwaysVisibleControlExtender ID="avce" runat="server">
<atlasToolkit:AlwaysVisibleControlProperties
TargetControlID="timer" />
</atlasToolkit:AlwaysVisibleControlExtender>


In the current release this wont work due to a "Known Issue" where you cant use extenders in a Template. However in future releases, you might want to consider trying to make a UserControl that contains your AlwaysVisibleControl. Then place the user control on your pages. This way, if you change your user control, you make changes across the board.


Another way may be to set the values on Page_load and store the values in your Web.Config file

Example:

Web.Config

<appSettings> <add key="MyValue" value="25"/> </appSettings>

My.aspx

Protected Sub Page_Load

MyAlwaysVisibleControlExtender.SomeProperty = ConfigurationManager.AppSettings("MyValue")

End Sub


That sounds like a bunch of hooey to me. Want to do the same thing with the new Ajax Beta 1.0 as you did in the CTP?

Remove Programs: Atlas, Atlas Documentation, Atlas Toolkit

Go tohttp://ajax.asp.net/

Download the ASP.NET AJAX v1.0 Beta. Specify C:\Downloads\AJAXBeta1.0 as the download

folder. Takes 14 seconds. Run.

Download and run CTP Beta at

http://www.microsoft.com/downloads/details.aspx?FamilyId=8A3FD0DD-D75E-4249-86DA-3D4AAC649652

&displaylang=en (link found at the bottom of second step).

At this pagehttp://ajax.asp.net/default.aspx?tabid=47&subtabid=477 download AJAX Toolkit.

Takes 26 seconds

Unzip into a new folder..

On this page

http://www.microsoft.com/downloads/details.aspx?familyid=90E0CCDF-D246-4929-A027-D5EE6F806851&

displaylang=en

In VWD 2005 Express, open website. Specify C:\DOWNLOADS\AJAXTOOKITUNZIPPED\SAMPLEWEBSITE.

Copy AlwaysVisibleControl.aspx and aspx.cs. Paste into AlwaysVisibleControl folder. Now, you have

a Copy of AlwaysVisibleControl. This will be the subject of our experiment. Close VWD 2005 Express.

Open Visual C# 2005 Express. Open Project. Specify

C:\DOWNLOADS\AJAXTOOKITUNZIPPED\AJAXCONTROLTOOLKIT SOLUTION. A number of warnings will

be issued - just click through them. Click checkbox "Load project NORMALLY". Keep clicking through

diagnostic error messages/boxes. Ultimately, you'll see the AjaxControlToolkit in Solution Explorer

(right side).

Select AlwaysVisibleControl folder. Double-click AlwaysVisibleControlBehavior.js

Modify code (example 55 and 34):

// Desired offset from the horizontal edge of the window
// this._horizontalOffset = 0;
this._horizontalOffset = 55;

// Desired offset from the vertical edge of the window
// this._verticalOffset = 0;
this._verticalOffset = 34;

Right-click AlwaysVisibleControlBehavior.js tab (upper-left). Save AlwaysVisibleControlBehavior.js.

Close AlwaysVisibleControlBehavior.js.

In Solution Explorer (right-side), right-click AjaxControlToolkit. "Build".

Close Visual C# 2005 Express.

Open VWD 2005 Express.

Open SampleWebsite.

Using Windows Explorer, search for "AjaxControlToolkit". Most recently modified should be

something like C:\Downloads\AJAXBeta1.0\AjaxControlToolkitUnzipped\AjaxControlToolkit\bin\Debug

and the .PDB file something like

C:\Downloads\AJAXBeta1.0\AjaxControlToolkitUnzipped\AjaxControlToolkit\bin\Debug

Copy and Paste (in essence, replacing) both into the bin in your project in VWD 2005 Express.

Open Copy of AlwaysVisibleControl.aspx.

Modify code so it looks like this:

<ajaxToolkit:AlwaysVisibleControlExtender
ID="avce" runat="server"
TargetControlID="timer"/>

Right-click within the IDE. Agree to "save your changes before previewing this file?"

The functionality works a-okay with the new Ajax Beta 1.0 release. And if

you're displeased with the new horizontal and vertical defaults we set in this exercise, you can still

override the parametric values in the AlwaysVisibleControl.aspx like so and that works too:

<ajaxToolkit:AlwaysVisibleControlExtender ID="avce" runat="server"
TargetControlID="timer"
VerticalSide="Top" VerticalOffset="100"
HorizontalSide="Right" HorizontalOffset="100"
ScrollEffectDuration=".1" />

So what's the issue with the new release?

No comments:

Post a Comment