3 // Permission is hereby granted, free of charge, to any person obtaining
4 // a copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to
8 // permit persons to whom the Software is furnished to do so, subject to
9 // the following conditions:
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 * Namespace : System.Web.UI.MobileControls.Adapters
25 * Class : HtmlCommandAdapter
26 * Author : Gaurav Vaish
28 * Copyright : 2003 with Gaurav Vaish, and with
33 using System
.Collections
.Specialized
;
34 using System
.Web
.Mobile
;
35 using System
.Web
.UI
.MobileControls
;
37 namespace System
.Web
.UI
.MobileControls
.Adapters
39 public class HtmlCommandAdapter
: HtmlControlAdapter
41 public HtmlCommandAdapter() : base()
45 protected new Command Control
49 return base.Control
as Command
;
53 public override bool LoadPostData(string postKey
,
54 NameValueCollection data
,
55 object privateControlData
, out bool dataChanged
)
61 string id
= Control
.UniqueID
;
62 string ctrl
= data
[id
+ ".x"];
63 string evnt
= data
[id
+ ".y"];
64 if(ctrl
!= null && evnt
!= null && ctrl
.Length
> 0 && evnt
.Length
> 0)
73 public override void Render(HtmlMobileTextWriter writer
)
75 bool supportsImgSbt
= false;
76 bool supportsJavascript
= false;
77 Form mobileForm
= null;
81 if(Control
.ImageUrl
!= String
.Empty
&& Device
.SupportsImageSubmit
)
83 supportsImgSbt
= true;
84 if(Control
.Format
== CommandFormat
.Link
)
88 supportsJavascript
= true;
93 if(supportsJavascript
)
95 writer
.EnterStyle(Style
);
96 mobileForm
= Control
.Form
;
97 if(mobileForm
.Action
.Length
> 0)
99 writer
.Write("<a href=\"javascript:document.");
100 writer
.Write(mobileForm
.ClientID
);
101 writer
.Write(".submit()\"");
102 base.AddAttributes(writer
);
104 writer
.WriteText(Control
.Text
, false);
105 writer
.WriteEndTag("a");
108 base.RenderBeginLink(writer
, Constants
.FormIDPrefix
+ mobileForm
.UniqueID
);
109 writer
.WriteText(Control
.Text
, true);
110 base.RenderEndLink(writer
);
112 writer
.ExitStyle(Style
, Control
.BreakAfter
);
115 writer
.EnterLayout(Style
);
116 writer
.WriteBeginTag("input");
117 writer
.WriteAttribute("name", Control
.UniqueID
);
120 writer
.WriteAttribute("type", "image");
121 writer
.WriteAttribute("src", Control
.ResolveUrl(Control
.ImageUrl
));
122 writer
.WriteAttribute("alt", Control
.Text
);
125 writer
.WriteAttribute("type", "submit");
126 writer
.Write("value=\"");
127 writer
.WriteText(Control
.Text
, true);
130 base.AddAttributes(writer
);
132 writer
.ExitLayout(Style
, Control
.BreakAfter
);