1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
//------------------------------------------------------------------------------
// <copyright file="WmlImageMapAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Globalization;
using System.Web.UI.WebControls;
using System.Web.UI.Adapters;
using System.Collections.Specialized;
using System.Web.Util;
// Adapts the ImageMap for wml.
public class WmlImageMapAdapter : ImageMapAdapter, IPostBackDataHandler, IPostBackEventHandler {
protected internal override void OnInit(EventArgs e) {
// NB: this is required because the control names do not match the controlID
Page.RegisterRequiresPostBack(Control);
base.OnInit(e);
}
protected internal override void Render(HtmlTextWriter writer) {
if (Control.HotSpots.Count > 0) {
HotSpotMode mapMode = Control.HotSpotMode;
if (mapMode == HotSpotMode.NotSet) {
mapMode = HotSpotMode.Navigate;
}
HotSpotMode spotMode;
int hotSpotIndex = 0;
string targetURL;
string text;
foreach (HotSpot item in Control.HotSpots) {
text = item.AlternateText;
if (text != null && text.Length == 0) {
text = item.NavigateUrl;
}
spotMode = item.HotSpotMode;
if (spotMode == HotSpotMode.NotSet) {
spotMode = mapMode;
}
if (spotMode == HotSpotMode.PostBack) {
PageAdapter.RenderPostBackEvent(writer, Control.ClientID, hotSpotIndex.ToString(CultureInfo.InvariantCulture),
null, text);
}
else if (spotMode == HotSpotMode.Navigate) {
targetURL = Control.ResolveClientUrl(item.NavigateUrl);
targetURL = Control.GetCountClickUrl(targetURL);
PageAdapter.RenderBeginHyperlink(writer, targetURL, true /* encode */, null, Control.AccessKey);
writer.Write(text);
PageAdapter.RenderEndHyperlink(writer);
}
else { //HotSpotMode.Inactive
writer.Write(LiteralControlAdapterUtility.ProcessWmlLiteralText(text));
}
++hotSpotIndex;
writer.WriteBreak();
}
}
}
/// <internalonly/>
bool IPostBackDataHandler.LoadPostData(String key, NameValueCollection data) {
return LoadPostData(key, data);
}
/// <internalonly/>
protected virtual bool LoadPostData(String key, NameValueCollection data) {
return false;
}
/// <internalonly/>
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
/// <internalonly/>
protected virtual void RaisePostDataChangedEvent() {
}
/// <internalonly/>
void IPostBackEventHandler.RaisePostBackEvent(string eventArgument) {
RaisePostBackEvent(eventArgument);
}
/// <internalonly/>
protected virtual void RaisePostBackEvent(string eventArgument) {
((IPostBackEventHandler)Control).RaisePostBackEvent(eventArgument);
}
}
}
#endif
|