VAR.WebFormsCore: Implement some controls.

This commit is contained in:
2021-06-20 04:21:26 +02:00
parent 42da0f6209
commit 211b500821
40 changed files with 559 additions and 195 deletions

View File

@@ -5,7 +5,7 @@ using System.Reflection;
using System.Text;
using Microsoft.AspNetCore.Http;
namespace VAR.WebForms.Common.Code
namespace VAR.WebFormsCore.Code
{
public class Bundler
{

View File

@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Http;
using VAR.Json;
namespace VAR.WebForms.Common.Code
namespace VAR.WebFormsCore.Code
{
public static class ExtensionMethods
{
@@ -9,13 +9,6 @@ namespace VAR.WebForms.Common.Code
public static string GetRequestParm(this HttpContext context, string parm)
{
foreach (string key in context.Request.Form.Keys)
{
if (string.IsNullOrEmpty(key) == false && key.EndsWith(parm))
{
return context.Request.Form[key];
}
}
foreach (string key in context.Request.Query.Keys)
{
if (string.IsNullOrEmpty(key) == false && key.EndsWith(parm))

View File

@@ -1,7 +1,7 @@
using System;
using System.Linq;
namespace VAR.WebForms.Common.Code
namespace VAR.WebFormsCore.Code
{
public static class GlobalConfig
{

View File

@@ -1,9 +1,9 @@
using System;
using System.Text;
using Microsoft.AspNetCore.Http;
using VAR.WebForms.Common.Pages;
using VAR.WebFormsCore.Pages;
namespace VAR.WebForms.Common.Code
namespace VAR.WebFormsCore.Code
{
public static class GlobalErrorHandler
{

View File

@@ -5,25 +5,25 @@ using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using VAR.WebForms.Common.Code;
namespace VAR.Focus.WebApp
namespace VAR.WebFormsCore.Code
{
// You may need to install the Microsoft.AspNetCore.Http.Abstractions package into your project
public class GlobalRouterMiddleware
{
private readonly RequestDelegate _next;
private readonly IWebHostEnvironment _env;
public GlobalRouterMiddleware(RequestDelegate next)
public GlobalRouterMiddleware(RequestDelegate next, IWebHostEnvironment env)
{
_next = next;
_env = env;
ServerHelpers.SetContentRoot(env.ContentRootPath);
}
public Task Invoke(HttpContext httpContext)
{
httpContext.Response.Headers.Remove("Server");
httpContext.Response.Headers.Remove("X-Powered-By");
httpContext.Response.Headers.Add("X-Content-Type-Options", "nosniff");
@@ -43,17 +43,12 @@ namespace VAR.Focus.WebApp
GlobalErrorHandler.HandleError(httpContext, ex);
}
//httpContext.Response.WriteAsync("Hello World!");
//return _next(httpContext);
return null;
}
private void RouteRequest(HttpContext context)
{
// TODO: need a replacement for context.Request.FilePath, using context.Request.Path for now
string path = context.Request.Path;
string file = Path.GetFileName(path);
if (string.IsNullOrEmpty(file))
@@ -65,8 +60,7 @@ namespace VAR.Focus.WebApp
string extension = Path.GetExtension(path).ToLower();
if (GlobalConfig.Get().AllowedExtensions.Contains(extension))
{
// TODO: need a replacement for context.Request.PhysicalPath, using context.Request.Path for now
string filePath = context.Request.Path;
string filePath = ServerHelpers.MapContentPath(path);
if (File.Exists(filePath))
{
StaticFileHelper.ResponseStaticFile(context, filePath);
@@ -82,8 +76,6 @@ namespace VAR.Focus.WebApp
}
// Use handler
//context.Response.Clear();
//context.Handler = handler;
handler.ProcessRequest(context);
}
@@ -154,12 +146,11 @@ namespace VAR.Focus.WebApp
}
// Extension method used to add the middleware to the HTTP request pipeline.
public static class GlobalRouterMiddlewareExtensions
{
public static IApplicationBuilder UseGlobalRouterMiddleware(this IApplicationBuilder builder)
public static IApplicationBuilder UseGlobalRouterMiddleware(this IApplicationBuilder builder, IWebHostEnvironment env)
{
return builder.UseMiddleware<GlobalRouterMiddleware>();
return builder.UseMiddleware<GlobalRouterMiddleware>(env);
}
}
}

View File

@@ -1,8 +1,7 @@
using System.Collections.Generic;
using System.Web;
using Microsoft.AspNetCore.Http;
namespace VAR.WebForms.Common.Code
namespace VAR.WebFormsCore.Code
{
public interface IGlobalConfig
{

View File

@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Http;
namespace VAR.WebForms.Common.Code
namespace VAR.WebFormsCore.Code
{
public interface IHttpHandler
{

View File

@@ -2,7 +2,7 @@
using System.IO;
using VAR.Json;
namespace VAR.WebForms.Common.Code
namespace VAR.WebFormsCore.Code
{
public class MultiLang
{

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq.Expressions;
namespace VAR.WebForms.Common.Code
namespace VAR.WebFormsCore.Code
{
public class ObjectActivator
{

View File

@@ -0,0 +1,9 @@
namespace VAR.WebFormsCore.Code
{
public class Program
{
public static void Main()
{
}
}
}

View File

@@ -1,22 +1,20 @@
using Microsoft.AspNetCore.Http;
using System.Reflection;
using Microsoft.AspNetCore.Http;
namespace VAR.WebForms.Common.Code
namespace VAR.WebFormsCore.Code
{
public class ScriptsBundler : IHttpHandler
{
#region IHttpHandler
public bool IsReusable { get { return false; } }
public void ProcessRequest(HttpContext context)
{
// TODO: Needs replacement for context.Server.MapPath
//Bundler bundler = new Bundler(
// assembly: Assembly.GetExecutingAssembly(),
// assemblyNamespace: "Scripts",
// absolutePath: context.Server.MapPath("~/Scripts/"));
//context.Response.PrepareCacheableResponse();
//bundler.WriteResponse(context.Response, "text/javascript");
Bundler bundler = new Bundler(
assembly: Assembly.GetExecutingAssembly(),
assemblyNamespace: "Scripts",
absolutePath: ServerHelpers.MapContentPath("Scripts"));
context.Response.PrepareCacheableResponse();
bundler.WriteResponse(context.Response, "text/javascript");
}
#endregion IHttpHandler

View File

@@ -0,0 +1,19 @@
using System.IO;
namespace VAR.WebFormsCore.Code
{
public class ServerHelpers
{
private static string _contentRoot = null;
public static void SetContentRoot(string contentRoot)
{
_contentRoot = contentRoot;
}
public static string MapContentPath(string path)
{
string mappedPath = Path.Combine(_contentRoot, path);
return mappedPath;
}
}
}

View File

@@ -2,7 +2,7 @@
using System.IO;
using Microsoft.AspNetCore.Http;
namespace VAR.WebForms.Common.Code
namespace VAR.WebFormsCore.Code
{
public class StaticFileHelper
{

View File

@@ -1,22 +1,20 @@
using Microsoft.AspNetCore.Http;
using System.Reflection;
using Microsoft.AspNetCore.Http;
namespace VAR.WebForms.Common.Code
namespace VAR.WebFormsCore.Code
{
public class StylesBundler : IHttpHandler
{
#region IHttpHandler
public bool IsReusable { get { return false; } }
public void ProcessRequest(HttpContext context)
{
// TODO: Needs replacement for context.Server.MapPath
//Bundler bundler = new Bundler(
// assembly: Assembly.GetExecutingAssembly(),
// assemblyNamespace: "Styles",
// absolutePath: context.Server.MapPath("~/Styles/"));
//context.Response.PrepareCacheableResponse();
//bundler.WriteResponse(context.Response, "text/css");
Bundler bundler = new Bundler(
assembly: Assembly.GetExecutingAssembly(),
assemblyNamespace: "Styles",
absolutePath: ServerHelpers.MapContentPath("Styles"));
context.Response.PrepareCacheableResponse();
bundler.WriteResponse(context.Response, "text/css");
}
#endregion IHttpHandler

View File

@@ -0,0 +1,32 @@
using System;
using System.IO;
namespace VAR.WebFormsCore.Controls
{
// TODO: Implememnt control
public class Button : Control
{
public Button()
{
CssClass = "button";
}
public string Text { get; set; }
public string CommandArgument { get; set; }
public event EventHandler Click;
public override void Render(TextWriter textWriter)
{
textWriter.Write("<input type=\"submit\" ");
RenderAttributes(textWriter);
RenderAttribute(textWriter, "value", Text);
textWriter.Write(">");
base.Render(textWriter);
textWriter.Write("</input>");
}
}
}

View File

@@ -1,18 +0,0 @@
using System;
namespace VAR.WebForms.Common.Controls
{
// TODO: Implememnt control
public class CButton : Control
{
public CButton()
{
CssClass = "button";
}
public string Text { get; set; }
public string CommandArgument { get; set; }
public event EventHandler Click;
}
}

View File

@@ -1,41 +0,0 @@
namespace VAR.WebForms.Common.Controls
{
// TODO: Implememnt control
public class CLabel : Control
{
#region Declarations
private string _tagName = "span";
#endregion Declarations
#region Properties
public string Tag
{
get { return _tagName; }
set { _tagName = value; }
}
public string Text { get; set; }
#endregion Properties
#region Life cycle
//public override void RenderBeginTag(HtmlTextWriter writer)
//{
// if (string.IsNullOrEmpty(_tagName) == false)
// {
// this.AddAttributesToRender(writer);
// writer.RenderBeginTag(_tagName);
// }
// else
// {
// base.RenderBeginTag(writer);
// }
//}
#endregion Life cycle
}
}

View File

@@ -2,11 +2,9 @@
using System.Collections.Generic;
using System.Text;
using VAR.Json;
using VAR.WebForms.Common.Pages;
namespace VAR.WebForms.Common.Controls
namespace VAR.WebFormsCore.Controls
{
// TODO: Implememnt control
public class CTextBox : Control, INamingContainer, IValidableControl
{
#region Declarations

View File

@@ -1,30 +1,202 @@
using System;
using System.Collections.Generic;
using VAR.WebForms.Common.Pages;
using System.IO;
using System.Text;
using VAR.WebFormsCore.Pages;
namespace VAR.WebForms.Common.Controls
namespace VAR.WebFormsCore.Controls
{
// TODO: Implememnt control
public class Control
{
public event EventHandler PreInit;
protected void OnPreInit()
{
PreInit?.Invoke(this, null);
foreach (Control control in Controls)
{
control.OnPreInit();
}
}
public event EventHandler Init;
protected void OnInit()
{
Init?.Invoke(this, null);
foreach (Control control in Controls)
{
control.OnInit();
}
}
public event EventHandler Load;
protected void OnLoad()
{
Load?.Invoke(this, null);
foreach (Control control in Controls)
{
control.OnLoad();
}
}
public event EventHandler PreRender;
public string CssClass { get; set; }
public List<Control> Controls { get; set; }
protected void OnPreRender()
{
PreRender?.Invoke(this, null);
foreach (Control control in Controls)
{
control.OnPreRender();
}
}
public bool Visible { get; set; }
private string _id = null;
public string ID { get; set; }
public string ID { get { return _id; } set { _id = value; _clientID = null; } }
public string ClientID { get; set; }
private string _clientID = null;
public Dictionary<string, string> Style { get; set; }
public string ClientID
{
get
{
if (_clientID == null)
{
_clientID = GenerateClientID();
}
return _clientID;
}
}
public Dictionary<string, string> Attributes { get; set; }
private Control _parent = null;
public Control Parent { get { return _parent; } set { _parent = value; _clientID = null; } }
private ControlCollection _controls = null;
private string _cssClass = null;
public string CssClass { get { return _cssClass; } set { _cssClass = value; } }
public ControlCollection Controls
{
get
{
if (_controls == null)
{
_controls = new ControlCollection(this);
}
return _controls;
}
}
private Page _page = null;
public Page Page
{
get { return _page; }
set
{
_page = value;
foreach (Control control in Controls)
{
control.Page = value;
}
}
}
private bool _visible = true;
public bool Visible { get { return _visible; } set { _visible = value; } }
private string GenerateClientID()
{
StringBuilder sbClientID = new();
if (string.IsNullOrEmpty(_id) == false)
{
sbClientID.Insert(0, _id);
}
else
{
string currentID = string.Format("ctl{0:00}", Index);
sbClientID.Insert(0, currentID);
}
Control parent = Parent;
while (parent != null)
{
if (parent is INamingContainer)
{
sbClientID.Insert(0, "_");
if (string.IsNullOrEmpty(parent.ID) == false)
{
sbClientID.Insert(0, parent.ID);
}
else
{
string parentID = string.Format("ctl{0:00}", parent.Index);
sbClientID.Insert(0, parentID);
}
}
parent = parent.Parent;
}
return sbClientID.ToString();
}
public Dictionary<string, string> Style { get; } = new Dictionary<string, string>();
public Dictionary<string, string> Attributes { get; } = new Dictionary<string, string>();
private int _index = 0;
public int Index { get { return _index; } set { _index = value; } }
public virtual void Render(TextWriter textWriter)
{
foreach (Control control in Controls)
{
if (control.Visible == false) { continue; }
control.Render(textWriter);
}
}
public void RenderAttribute(TextWriter textWriter, string key, string value)
{
textWriter.Write(" {0}=\"{1}\"", key, value);
}
protected void RenderAttributes(TextWriter textWriter)
{
if (string.IsNullOrEmpty(_id) == false)
{
RenderAttribute(textWriter, "id", ClientID);
RenderAttribute(textWriter, "name", ClientID);
}
if (string.IsNullOrEmpty(_cssClass) == false)
{
RenderAttribute(textWriter, "class", _cssClass);
}
foreach (KeyValuePair<string, string> attributePair in Attributes)
{
RenderAttribute(textWriter, attributePair.Key, attributePair.Value);
}
if (Style.Count > 0)
{
StringBuilder sbStyle = new();
foreach (KeyValuePair<string, string> stylePair in Style)
{
sbStyle.AppendFormat("{0}: {1};", stylePair.Key, stylePair.Value);
}
RenderAttribute(textWriter, "style", sbStyle.ToString());
}
}
public Page Page { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
using System.Collections.Generic;
namespace VAR.WebFormsCore.Controls
{
public class ControlCollection : List<Control>
{
private Control _parent = null;
private int _index = 0;
public ControlCollection(Control parent)
{
_parent = parent;
}
public new void Add(Control control)
{
control.Page = _parent.Page;
control.Parent = _parent;
control.Index = _index;
_index++;
base.Add(control);
}
}
}

View File

@@ -1,8 +1,21 @@
namespace VAR.WebForms.Common.Controls
using System.IO;
namespace VAR.WebFormsCore.Controls
{
// TODO: Implememnt control
public class HiddenField : Control
{
public string Value { get; set; }
public override void Render(TextWriter textWriter)
{
textWriter.Write("<input type=\"hidden\" ");
RenderAttributes(textWriter);
if (string.IsNullOrEmpty(Value) == false)
{
textWriter.Write(" value=\"{0}\"", Value);
}
textWriter.Write(">");
textWriter.Write("</input>");
}
}
}

View File

@@ -1,8 +1,7 @@
using VAR.WebForms.Common.Controls;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Controls
{
public class HtmlBody : Control
public class HtmlBody : HtmlGenericControl
{
public HtmlBody() : base("body") { }
}
}

View File

@@ -1,8 +1,8 @@
using VAR.WebForms.Common.Controls;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Controls
{
public class HtmlForm : Control
// TODO: Implment this control
public class HtmlForm : HtmlGenericControl
{
public HtmlForm() : base("form") { }
}
}

View File

@@ -1,14 +1,25 @@
using VAR.WebForms.Common.Controls;
using System.IO;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Controls
{
public class HtmlGenericControl : Control
{
private string _tag;
private string _tagName;
public HtmlGenericControl(string tag)
{
this._tag = tag;
_tagName = tag;
}
public override void Render(TextWriter textWriter)
{
textWriter.Write("<{0} ", _tagName);
RenderAttributes(textWriter);
textWriter.Write(">");
base.Render(textWriter);
textWriter.Write("</{0}>", _tagName);
}
}
}

View File

@@ -1,9 +1,25 @@
using VAR.WebForms.Common.Controls;
using System.IO;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Controls
{
public class HtmlHead : Control
{
public string Title { get; internal set; }
public string Title { get; set; }
public override void Render(TextWriter textWriter)
{
textWriter.Write("<head ");
RenderAttributes(textWriter);
textWriter.Write(">");
if (string.IsNullOrEmpty(Title) == false)
{
textWriter.Write("<title>{0}</title>", Title);
}
base.Render(textWriter);
textWriter.Write("</head>");
}
}
}

View File

@@ -1,11 +1,29 @@
using VAR.WebForms.Common.Controls;
using System.IO;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Controls
{
public class HtmlMeta : Control
{
public string Name { get; set; }
public string Content { get; set; }
public string HttpEquiv { get; internal set; }
public override void Render(TextWriter textWriter)
{
textWriter.Write("<meta ");
RenderAttributes(textWriter);
if (string.IsNullOrEmpty(Name) == false)
{
textWriter.Write(" name=\"{0}\"", Name);
}
if (string.IsNullOrEmpty(Content) == false)
{
textWriter.Write(" content=\"{0}\"", Content);
}
if (string.IsNullOrEmpty(HttpEquiv) == false)
{
textWriter.Write(" http-equiv=\"{0}\"", HttpEquiv);
}
textWriter.Write(" />");
}
}
}

View File

@@ -1,11 +1,32 @@
using VAR.WebForms.Common.Controls;
using System.IO;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Controls
{
public class HyperLink : Control
{
public string NavigateUrl { get; set; }
public string Text { get; set; }
public override void Render(TextWriter textWriter)
{
textWriter.Write("<a ");
RenderAttributes(textWriter);
if (string.IsNullOrEmpty(NavigateUrl) == false)
{
textWriter.Write(" href=\"{0}\"", NavigateUrl);
}
textWriter.Write(">");
if (string.IsNullOrEmpty(Text) == false)
{
textWriter.Write(Text);
}
base.Render(textWriter);
textWriter.Write("</a>");
}
}
}

View File

@@ -1,4 +1,4 @@
namespace VAR.WebForms.Common.Controls
namespace VAR.WebFormsCore.Controls
{
public interface INamingContainer
{

View File

@@ -1,4 +1,4 @@
namespace VAR.WebForms.Common.Controls
namespace VAR.WebFormsCore.Controls
{
public interface IValidableControl
{

View File

@@ -0,0 +1,43 @@
using System.IO;
namespace VAR.WebFormsCore.Controls
{
// TODO: Implememnt control
public class Label : Control
{
#region Declarations
private string _tagName = "span";
#endregion Declarations
#region Properties
public string Tag
{
get { return _tagName; }
set { _tagName = value; }
}
public string Text { get; set; }
#endregion Properties
#region Life cycle
public override void Render(TextWriter textWriter)
{
textWriter.Write("<{0} ", _tagName);
RenderAttributes(textWriter);
textWriter.Write(">");
textWriter.Write(Text);
base.Render(textWriter);
textWriter.Write("</{0}>", _tagName);
}
#endregion Life cycle
}
}

View File

@@ -1,6 +1,6 @@
using VAR.WebForms.Common.Controls;
using System.IO;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Controls
{
public class LiteralControl : Control
{
@@ -9,5 +9,10 @@ namespace VAR.WebForms.Common.Pages
public LiteralControl() { }
public LiteralControl(string content) { Content = content; }
public override void Render(TextWriter textWriter)
{
textWriter.Write(Content);
}
}
}

View File

@@ -1,12 +1,8 @@
using VAR.WebForms.Common.Controls;
using VAR.WebFormsCore.Code;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Controls
{
// TODO: Implememnt control
public class Panel : Control
public class Panel : HtmlGenericControl
{
public Unit Width { get; set; }
public Unit Height { get; set; }
public Panel() : base("div") { }
}
}

View File

@@ -1,4 +1,6 @@
namespace VAR.WebForms.Common.Controls
using System.IO;
namespace VAR.WebFormsCore.Controls
{
// TODO: Implememnt control
public class TextBox : Control
@@ -6,6 +8,40 @@
public string Text { get; set; }
public TextBoxMode TextMode { get; set; } = TextBoxMode.Normal;
public override void Render(TextWriter textWriter)
{
if (TextMode == TextBoxMode.MultiLine)
{
textWriter.Write("<textare ");
RenderAttributes(textWriter);
textWriter.Write(">");
textWriter.Write(Text);
textWriter.Write("</textare>");
}
else if (TextMode == TextBoxMode.Normal)
{
textWriter.Write("<input type=\"text\" ");
RenderAttributes(textWriter);
if (string.IsNullOrEmpty(Text) == false)
{
RenderAttribute(textWriter, "value", Text);
}
textWriter.Write(">");
textWriter.Write("</input>");
}
else if (TextMode == TextBoxMode.Password)
{
textWriter.Write("<input type=\"password\" ");
RenderAttributes(textWriter);
if (string.IsNullOrEmpty(Text) == false)
{
RenderAttribute(textWriter, "value", Text);
}
textWriter.Write(">");
textWriter.Write("</input>");
}
}
}
public enum TextBoxMode

View File

@@ -1,7 +1,6 @@
using System.Collections.Generic;
using VAR.WebForms.Common.Controls;
using VAR.WebFormsCore.Controls;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Pages
{
public class FormUtils
{
@@ -35,7 +34,7 @@ namespace VAR.WebForms.Common.Pages
if (string.IsNullOrEmpty(label) == false)
{
CLabel lblField = new CLabel();
Label lblField = new Label();
lblField.Text = label;
pnlLabelContainer.Controls.Add(lblField);
}
@@ -61,7 +60,7 @@ namespace VAR.WebForms.Common.Pages
return true;
}
public static bool Controls_AreValid(List<Control> controls)
public static bool Controls_AreValid(ControlCollection controls)
{
bool valid = true;
foreach (Control control in controls)

View File

@@ -1,18 +1,13 @@
using Microsoft.AspNetCore.Http;
using VAR.Json;
using VAR.WebForms.Common.Code;
using VAR.WebFormsCore.Code;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Pages
{
public class FrmEcho : IHttpHandler
{
#region IHttpHandler
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
context.Response.WriteAsync("<pre><code>");

View File

@@ -1,8 +1,8 @@
using System;
using System.Web;
using VAR.WebForms.Common.Controls;
using VAR.WebFormsCore.Controls;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Pages
{
public class FrmError : PageCommon
{
@@ -16,6 +16,7 @@ namespace VAR.WebForms.Common.Pages
public FrmError(Exception ex)
{
MustBeAutenticated = false;
_ex = ex;
Init += FrmError_Init;
}
@@ -33,18 +34,18 @@ namespace VAR.WebForms.Common.Pages
{
Title = "Application Error";
CLabel lblErrorTitle = new CLabel { Text = Title, Tag = "h2" };
Label lblErrorTitle = new Label { Text = Title, Tag = "h2" };
Controls.Add(lblErrorTitle);
Exception exAux = _ex;
//if (exAux is HttpUnhandledException && exAux.InnerException != null) { exAux = exAux.InnerException; }
while (exAux != null)
{
CLabel lblMessage = new CLabel { Tag = "P" };
Label lblMessage = new Label { Tag = "P" };
lblMessage.Text = string.Format("<b>{0}:</b> {1}", "Message", HttpUtility.HtmlEncode(exAux.Message));
Controls.Add(lblMessage);
CLabel lblStacktraceTitle = new CLabel { Tag = "p" };
Label lblStacktraceTitle = new Label { Tag = "p" };
lblStacktraceTitle.Text = string.Format("<b>{0}:</b>", "Stacktrace");
Controls.Add(lblStacktraceTitle);
Panel pnlStacktrace = new Panel();

View File

@@ -1,8 +1,9 @@
using Microsoft.AspNetCore.Http;
using VAR.WebForms.Common.Code;
using VAR.WebForms.Common.Controls;
using System.IO;
using Microsoft.AspNetCore.Http;
using VAR.WebFormsCore.Code;
using VAR.WebFormsCore.Controls;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Pages
{
// TODO: Implement Page
public class Page : Control, IHttpHandler
@@ -13,8 +14,19 @@ namespace VAR.WebForms.Common.Pages
public void ProcessRequest(HttpContext context)
{
StringWriter stringWriter = new();
Context = context;
throw new System.NotImplementedException();
Page = this;
OnPreInit();
OnInit();
OnLoad();
OnPreRender();
Render(stringWriter);
context.Response.Headers.Add("Content-Type", "text/html");
Context.Response.WriteAsync(stringWriter.ToString());
}
public bool IsPostBack { get; }

View File

@@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using VAR.WebForms.Common.Code;
using VAR.WebForms.Common.Controls;
using VAR.WebFormsCore.Code;
using VAR.WebFormsCore.Controls;
namespace VAR.WebForms.Common.Pages
namespace VAR.WebFormsCore.Pages
{
public class PageCommon : Page
{
@@ -14,8 +13,8 @@ namespace VAR.WebForms.Common.Pages
private HtmlBody _body;
private HtmlForm _form;
private Panel _pnlContainer = new Panel();
private CButton _btnPostback = new CButton();
private CButton _btnLogout = new CButton();
private Button _btnPostback = new Button();
private Button _btnLogout = new Button();
private bool _mustBeAutenticated = true;
private bool _isAuthenticated = false;
@@ -24,7 +23,7 @@ namespace VAR.WebForms.Common.Pages
#region Properties
public new List<Control> Controls
public new ControlCollection Controls
{
get { return _pnlContainer.Controls; }
}
@@ -120,7 +119,7 @@ namespace VAR.WebForms.Common.Pages
lnkTitle.NavigateUrl = ".";
pnlHeader.Controls.Add(lnkTitle);
var lblTitle = new CLabel { Text = GlobalConfig.Get().Title, Tag = "h1" };
var lblTitle = new Label { Text = GlobalConfig.Get().Title, Tag = "h1" };
lnkTitle.Controls.Add(lblTitle);
_btnPostback.ID = "btnPostback";

View File

@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:58454/",
"sslPort": 44386
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"VAR.WebFormsCore": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}

View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
@@ -21,7 +21,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="VAR.Json" Version="1.2.2" />
</ItemGroup>