Welcome to mirror list, hosted at ThFree Co, Russian Federation.

HtmlForm.cs « System.Web.UI.HtmlControls « System.Web « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1df7b2f270ad349775c011fbabe2b7a68488a6b8 (plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*	System.Web.UI.HtmlControls
*	Authors
*		Leen Toelen (toelen@hotmail.com)
*/

using System;
using System.Web;
using System.Web.UI;

namespace System.Web.UI.HtmlControls{
	
	public class HtmlForm : HtmlContainerControl{
		
		private static string SmartNavIncludeScriptKey  = "SmartNavIncludeScript";
		
		public HtmlForm(): base("form"){}
				
		protected override void RenderAttributes(HtmlTextWriter writer){
			writer.WriteAttribute("name",RenderedName);
			Attributes.Remove("name");
			writer.WriteAttribute("method",Method);
			Attributes.Remove("method");
			writer.WriteAttribute("action",Action,true);
			Attributes.Remove("action");
			if (Enctype != null){
				writer.WriteAttribute ("enctype", Enctype);
				Attributes.Remove ("enctype");
			}
				

//			string clientOnSubmit = Page.ClientOnSubmitEvent;
// 			if (clientOnSubmit != null && clientOnSubmit.Length > 0){
// 				if (Attributes["onsubmit"] != null){
// 					clientOnSubmit = String.Concat(clientOnSubmit,Attributes["onsubmit"]);
// 					Attributes.Remove("onsubmit");
// 				}
// 				writer.WriteAttribute("language","javascript");
// 				writer.WriteAttribute("onsubmit",clientOnSubmit);
// 			}
			if (ID == null){
				writer.WriteAttribute("id",ClientID);
			}
			base.RenderAttributes(writer);
		}
		
		protected override void Render(HtmlTextWriter output){
			if (Page.SmartNavigation == false){
				base.Render (output);
				return;
			}

			((IAttributeAccessor) this).SetAttribute("_smartNavigation","true");
			HttpBrowserCapabilities browserCap = Context.Request.Browser;
			if (browserCap.Browser.ToLower() != "ie" && browserCap.MajorVersion < 5){
				base.Render(output);
				return;
			}
			output.WriteLine("<IFRAME ID=_hifSmartNav NAME=_hifSmartNav STYLE=display:none ></IFRAME>");
				
			if (browserCap.MinorVersion < 0.5 && browserCap.MajorVersion != 5)
				Page.RegisterClientScriptFile("SmartNavIncludeScript","JScript","SmartNavIE5.js");
			else if (Page.IsPostBack) Page.RegisterClientScriptFile("SmartNavIncludeScript","JScript","SmartNav.js");
			base.Render(output);
		}
		
		protected override void RenderChildren (HtmlTextWriter writer)
		{
			Page.OnFormRender (writer,ClientID);
			base.RenderChildren (writer);
			Page.OnFormPostRender (writer,ClientID);
		}
		
		protected override void OnInit(EventArgs e){
			base.OnInit(e);
			Page.RegisterViewStateHandler();
		}
		
		internal string Action{
			get{
				string executionFilePath = Context.Request.CurrentExecutionFilePath;
				string filePath = Context.Request.FilePath;
				string attr;
				if (String.ReferenceEquals(executionFilePath, filePath) == true){
					attr = filePath;
					int lastSlash = attr.LastIndexOf('/');
					if (lastSlash >= 0)
						attr = attr.Substring(lastSlash + 1);
				}
				else{
					attr = System.Web.Utils.UrlUtils.MakeRelative(filePath,executionFilePath);
				}
				string queryString = Context.Request.QueryStringRaw;
				if (queryString != null && queryString.Length > 0)
					attr = String.Concat(attr, '?', queryString);
				return attr;
			}
		}
		
		public string Enctype{
			get{
				string attr = Attributes["enctype"];
				if (attr != null){
					return attr;
				}
				return null;
			}
			set{
				Attributes["enctype"] = AttributeToString(value);
			}
		}
		
		public string Method{
			get{
				string attr = Attributes["method"];
				if (attr != null){
					return attr;
				}
				return "post";
			}
			set{
				Attributes["method"] = AttributeToString(value);
			}
		}
		
		public string Target{
			get{
				string attr = Attributes["target"];
				if (attr != null){
					return attr;
				}
				return String.Empty;
			}
			set{
				Attributes["target"] = AttributeToString(value);
			}
		}
		
		public string Name{
			get{
				string attr = Attributes["name"];
				if (attr != null){
					return attr;
				}
				return String.Empty;
			}
			set {
				Attributes ["Name"] = value;
			}
		}
		
		internal string RenderedName{
			get{
				string attr = Name;
				if (attr.Length > 0){
					return attr;
				}
				return UniqueID;
			}
		}
		
	} // class HtmlForm
} // namespace System.Web.UI.HtmlControls