Test the HTMLFORM class under the System.web.ui.htmlControls, which is the formor object we use in the traditional ASP.NET, which is not suitable for dynamically generating HTML code.
So I customized a simple HTMLFORM container control, only a few lines of code. It seems that ASP.NET is still very advantageous in packaging HTML elements. Microsoft defines us for us
A large amount of infrastructure is easy to expand.
Public Class MyHTMLFORM: HtmlContainerControl {Public MyHTMLFORM (): Base (Form) {This.attributes.add (METHOD, Post);} Public String Action {Set {Attributes.add (action, value);}}}
It is simple to use, directly new, and then add a control to the Controls set.
MyHTMLFORM form = new myHtmlform (); form.id = myform; form.action = test.aspx; htmlinputhidden hidf = new htmlinputhidd (); hidf.id = hidf.name = hidden; form.controls.add (hidf);
Finally, in View, output HTML code to the response flow.
form.rendControl (writer);
in conclusion:
The dynamic HTML form is so simple and clear. I used to stitch HTML myself, and then write. Good at using the class provided by the framework can effectively improve the open efficiency,
And make the code read well. Especially when making table controls, using System.web.ui.webControls.table control will be very helpful. I really want to know PHP or other
Does language have these easy -to -use infrastructure?