2 // System.Web.UI.Adapters.PageAdapter
5 // Dick Porter <dick@ximian.com>
7 // Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Web.UI.WebControls;
31 using System.Collections;
32 using System.Collections.Specialized;
34 namespace System.Web.UI.Adapters
36 public abstract class PageAdapter : ControlAdapter
38 protected PageAdapter ()
42 internal PageAdapter (Page p) : base (p)
46 public virtual StringCollection CacheVaryByHeaders {
50 public virtual StringCollection CacheVaryByParams {
54 protected string ClientState
57 return Page.GetSavedViewState ();
61 public virtual NameValueCollection DeterminePostBackMode ()
63 return Page.DeterminePostBackMode ();
66 public virtual ICollection GetRadioButtonsByGroup (string groupName)
68 if (radio_button_group == null)
69 return new ArrayList();
70 ArrayList radioButtons = (ArrayList) radio_button_group [groupName];
71 if (radioButtons == null)
72 return new ArrayList();
76 public virtual PageStatePersister GetStatePersister ()
78 return new HiddenFieldPageStatePersister ((Page)Control);
81 public virtual void RegisterRadioButton (RadioButton radioButton)
83 if (radio_button_group == null)
84 radio_button_group = new ListDictionary();
85 ArrayList radioButtons = (ArrayList) radio_button_group [radioButton.GroupName];
86 if (radioButtons == null)
87 radio_button_group [radioButton.GroupName] = radioButtons = new ArrayList();
88 if (!radioButtons.Contains(radioButton))
89 radioButtons.Add(radioButton);
92 public virtual void RenderBeginHyperlink (HtmlTextWriter writer,
97 InternalRenderBeginHyperlink (writer, targetUrl, encodeUrl, softkeyLabel, null);
100 public virtual void RenderBeginHyperlink (HtmlTextWriter writer,
106 if (accessKey != null && accessKey.Length > 1)
107 throw new ArgumentOutOfRangeException("accessKey");
108 InternalRenderBeginHyperlink (writer, targetUrl, encodeUrl, softkeyLabel, accessKey);
111 void InternalRenderBeginHyperlink (HtmlTextWriter w,
117 w.AddAttribute (HtmlTextWriterAttribute.Href, targetUrl, encodeUrl);
118 if (accessKey != null)
119 w.AddAttribute (HtmlTextWriterAttribute.Accesskey, accessKey);
120 w.RenderBeginTag (HtmlTextWriterTag.A);
124 public virtual void RenderEndHyperlink (HtmlTextWriter writer)
126 writer.RenderEndTag();
129 public virtual void RenderPostBackEvent (HtmlTextWriter writer,
135 RenderPostBackEvent (writer, target, argument, softkeyLabel, text, Page.Request.FilePath, null, true);
138 public virtual void RenderPostBackEvent (HtmlTextWriter writer,
146 RenderPostBackEvent (writer, target, argument, softkeyLabel, text, postUrl, accessKey, true);
149 protected void RenderPostBackEvent (HtmlTextWriter writer,
158 string url = String.Format ("{0}?__VIEWSTATE={1}&__EVENTTARGET={2}&__EVENTARGUMENT={3}&__PREVIOUSPAGE={4}",
159 postUrl, HttpUtility.UrlEncode (Page.GetSavedViewState ()), target, argument, Page.Request.FilePath);
160 RenderBeginHyperlink (writer, url, encode, softkeyLabel, accessKey);
162 RenderEndHyperlink(writer);
165 public virtual string TransformText (string text)
170 protected internal virtual string GetPostBackFormReference (string formId)
172 return String.Format("document.forms['{0}']", formId);
175 ListDictionary radio_button_group;