mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
* HtmlSelect.cs (TrackViewState): Added 'new' keyword to avoid clashing with the method defined in the parent class. (OnDataBinding): Added missing casts. * HtmlForm.cs (Render): Fixed call too SetAttribute, need to cast 'this' to IAttributeAccessor before calling interface method. Also renamed some calls to reflect changes in the API. * HtmlControl.cs (WriteOnClickAttribute): Made it not static and fixed a typo. svn path=/trunk/mcs/; revision=4485
153 lines
4.0 KiB
C#
153 lines
4.0 KiB
C#
/* System.Web.UI.HtmlControls
|
|
* Authors
|
|
* Leen Toelen ([email protected])
|
|
*/
|
|
|
|
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 new 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");
|
|
|
|
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);
|
|
}
|
|
|
|
//TODO: adapt code for non-IE browsers
|
|
protected override void Render(HtmlTextWriter output){
|
|
if (Page.SmartNavigation == true){
|
|
((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;
|
|
}
|
|
}
|
|
|
|
internal string RenderedName{
|
|
get{
|
|
string attr = Name;
|
|
if (attr.Length > 0){
|
|
return attr;
|
|
}
|
|
return UniqueID;
|
|
}
|
|
}
|
|
|
|
} // class HtmlForm
|
|
} // namespace System.Web.UI.HtmlControls
|
|
|