(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Web.Mobile / System.Web.UI.MobileControls.Adapters / HtmlCommandAdapter.cs
blob0511ebf9ba6fb164e276442c2d7e84f81ed809ca
2 //
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:
10 //
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
13 //
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.
22 /**
23 * Project : Mono
24 * Namespace : System.Web.UI.MobileControls.Adapters
25 * Class : HtmlCommandAdapter
26 * Author : Gaurav Vaish
28 * Copyright : 2003 with Gaurav Vaish, and with
29 * Ximian Inc
32 using System;
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
47 get
49 return base.Control as Command;
53 public override bool LoadPostData(string postKey,
54 NameValueCollection data,
55 object privateControlData, out bool dataChanged)
57 dataChanged = false;
58 bool retVal = false;
59 if(Control != null)
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)
66 dataChanged = true;
67 retVal = true;
70 return retVal;
73 public override void Render(HtmlMobileTextWriter writer)
75 bool supportsImgSbt = false;
76 bool supportsJavascript = false;
77 Form mobileForm = null;
79 if(Control != null)
81 if(Control.ImageUrl != String.Empty && Device.SupportsImageSubmit)
83 supportsImgSbt = true;
84 if(Control.Format == CommandFormat.Link)
86 if(Device.JavaScript)
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);
103 writer.Write(">");
104 writer.WriteText(Control.Text, false);
105 writer.WriteEndTag("a");
106 } else
108 base.RenderBeginLink(writer, Constants.FormIDPrefix + mobileForm.UniqueID);
109 writer.WriteText(Control.Text, true);
110 base.RenderEndLink(writer);
112 writer.ExitStyle(Style, Control.BreakAfter);
113 } else
115 writer.EnterLayout(Style);
116 writer.WriteBeginTag("input");
117 writer.WriteAttribute("name", Control.UniqueID);
118 if(supportsImgSbt)
120 writer.WriteAttribute("type", "image");
121 writer.WriteAttribute("src", Control.ResolveUrl(Control.ImageUrl));
122 writer.WriteAttribute("alt", Control.Text);
123 } else
125 writer.WriteAttribute("type", "submit");
126 writer.Write("value=\"");
127 writer.WriteText(Control.Text, true);
129 writer.Write("\"");
130 base.AddAttributes(writer);
131 writer.Write("/>");
132 writer.ExitLayout(Style, Control.BreakAfter);