C # generate HTML control code

Source: Internet
Author: User

Log on to http: // 121.18.78.216/
# Region Generation Control
/// <Summary>
/// Table
/// </Summary>
/// <Returns> </returns>
Public static htmlgenericcontrol gethtmltable ()
{
Htmlgenericcontrol control = new htmlgenericcontrol ("table ");
Control. enableviewstate = false;
Control. Attributes. Add ("cellpadding", "0 ");
Control. Attributes. Add ("cellspacing", "0 ");
Return control;
}
/// <Summary>
/// Img
/// </Summary>
/// <Param name = "url"> </param>
/// <Param name = "title"> </param>
/// <Returns> </returns>
Public static htmlgenericcontrol gethtmlimg (string URL, String title)
{
Htmlgenericcontrol control = new htmlgenericcontrol ("IMG ");
Control. enableviewstate = false;
Control. Attributes. Add ("src", geturl (URL ));
If (! String. isnullorempty (title ))
{
Control. Attributes. Add ("title", title );
Control. Attributes. Add ("Alt", title );
}
Control. Attributes. Add ("Bolder", "0 ");
Return control;
}
/// <Summary>
///
/// </Summary>
/// <Param name = "url"> </param>
/// <Param name = "title"> </param>
/// <Param name = "target"> </param>
/// <Returns> </returns>
Public static htmlgenericcontrol gethtmla (string URL, String title, string target)
{
Htmlgenericcontrol control = new htmlgenericcontrol ("");
Control. enableviewstate = false;
If (string. isnullorempty (title ))
{
Control. innerhtml = "Link ";
}
Else
{
Control. innerhtml = title;
}
Control. Attributes. Add ("target", target );
If (string. isnullorempty (URL ))
{
Control. Disabled = true;
}
Else
{
Control. Attributes. Add ("href", geturl (URL ));
}
Return control;
}
/// <Summary>
/// Input
/// </Summary>
/// <Param name = "ID"> </param>
/// <Param name = "value"> </param>
/// <Param name = "width"> </param>
/// <Returns> </returns>
Public static htmlgenericcontrol gethtmlinput (string ID, string value, string width)
{
Htmlgenericcontrol control = new htmlgenericcontrol ("input ");
Control. enableviewstate = false;
If (! String. isnullorempty (ID ))
{
Control. Attributes. Add ("ID", ID );
Control. Attributes. Add ("name", ID );
}
If (! String. isnullorempty (value )&&! Value. Equals ("% "))
{
Control. Attributes. Add ("value", value );
}
Setwidth (control, width );
Return control;
}
/// <Summary>
/// Input text
/// </Summary>
/// <Param name = "ID"> </param>
/// <Param name = "value"> </param>
/// <Param name = "width"> </param>
/// <Param name = "maxlength"> </param>
/// <Returns> </returns>
Public static htmlgenericcontrol gethtmltext (string ID, string value, string width, int maxlength)
{
Htmlgenericcontrol control = gethtmlinput (ID, value, width );
Control. Attributes. Add ("type", "text ");
If (maxlength> 0)
{
Control. Attributes. Add ("maxlength", maxlength. tostring ());
}
Return control;
}
/// <Summary>
/// Area
/// </Summary>
/// <Param name = "ID"> </param>
/// <Param name = "value"> </param>
/// <Param name = "width"> </param>
/// <Param name = "rows"> </param>
/// <Returns> </returns>
Public static htmlgenericcontrol gethtmlarea (string ID, string value, string width, string rows)
{
Htmlgenericcontrol control = new htmlgenericcontrol ("textarea ");
Control. enableviewstate = false;
If (! String. isnullorempty (ID ))
{
Control. Attributes. Add ("ID", ID );
Control. Attributes. Add ("name", ID );
}
If (! String. isnullorempty (value )&&! Value. Equals ("% "))
{
Control. innerhtml = value;
}
Control. Attributes. Add ("rows", datahelper. getintvalue (rows, 10). tostring ());
Setwidth (control, width );
Return control;
}
/// <Summary>
/// Input button
/// </Summary>
/// <Param name = "ID"> </param>
/// <Param name = "value"> </param>
/// <Param name = "width"> </param>
/// <Returns> </returns>
Public static htmlgenericcontrol gethtmlbutton (string ID, string value, string width)
{
Htmlgenericcontrol control = gethtmlinput (ID, value, width );
Control. Attributes. Add ("type", "button ");
Return control;
}
/// <Summary>
/// If the generated image button does not exist, it is a normal button.
/// </Summary>
/// <Param name = "ID"> </param>
/// <Param name = "imgsrc"> </param>
/// <Param name = "title"> </param>
/// <Param name = "width"> </param>
/// <Returns> </returns>
Public static htmlgenericcontrol getimagebutton (string ID, string imgsrc, String title, string width)
{
Htmlgenericcontrol control = new htmlgenericcontrol ("input ");
Control. enableviewstate = false;
If (! String. isnullorempty (ID ))
{
Control. Attributes. Add ("ID", ID );
Control. Attributes. Add ("name", ID );
}
If (! String. isnullorempty (title ))
{
Control. Attributes. Add ("value", title );
}
If (string. isnullorempty (imgsrc ))
{
Control. Attributes. Add ("type", "button ");
}
Else
{
Control. Attributes. Add ("type", "image ");
Control. Attributes. Add ("src", getrootpath () + imgsrc. trimstart ('/'));
If (! String. isnullorempty (title ))
{
Control. Attributes. Add ("title", title );
}
}
Setwidth (control, width );
Return control;
}
/// <Summary>
/// Input checkbox
/// </Summary>
/// <Param name = "ID"> </param>
/// <Param name = "value"> </param>
/// <Returns> </returns>
Public static htmlgenericcontrol gethtmlcheckbox (string ID, string value)
{
Htmlgenericcontrol control = gethtmlinput (ID, null, null );
Control. Attributes. Add ("type", "checkbox ");
If (! String. isnullorempty (value ))
{
Control. Attributes. Add ("checked", "true ");
}
Return control;
}
/// <Summary>
/// Select
/// </Summary>
/// <Param name = "ID"> </param>
/// <Param name = "value"> </param>
/// <Param name = "width"> </param>
/// <Param name = "selects"> the set value of the title value is displayed. </param>
/// <Returns> </returns>
Public static htmlgenericcontrol gethtmlselect (string ID, string value, string width, namevaluecollection selects)
{
Htmlgenericcontrol control = new htmlgenericcontrol ("select ");
Control. enableviewstate = false;
If (! String. isnullorempty (ID ))
{
Control. Attributes. Add ("ID", ID );
Control. Attributes. Add ("name", ID );
}
Setwidth (control, width );
If (selects! = NULL)
{
For (INT I = 0; I <selects. Count; I ++)
{
Htmlgenericcontrol option = new htmlgenericcontrol ("option ");
Option. enableviewstate = false;
Option. Attributes. Add ("value", selects. getkey (I ));
Option. innerhtml = selects. Get (I). Replace ("", "& nbsp ;");
If (selects. getkey (I) = value)
{
Option. Attributes. Add ("selected", "selected ");
}
Control. Controls. Add (option );
}
}
Return control;
}
/// <Summary>
/// Obtain the span
/// </Summary>
/// <Param name = "text"> </param>
/// <Returns> </returns>
Public static htmlgenericcontrol getspan (string text)
{
Htmlgenericcontrol control = new htmlgenericcontrol ("span ");
Control. enableviewstate = false;
If (! String. isnullorempty (text ))
{
Control. innerhtml = text;
}
Return control;
}
/// <Summary>
/// Obtain the text Control
/// </Summary>
/// <Param name = "text"> text value </param>
/// <Returns> </returns>
Public static literal getliteral (string text)
{
Literal tenant = new literal ();
Enabled. enableviewstate = false;
Gradient. Text = text;
Return response;
}
/// <Summary>
/// Obtain the Space Control
/// </Summary>
/// <Returns> </returns>
Public static literal getspace ()
{
Literal tenant = new literal ();
Enabled. enableviewstate = false;
Vertex. Text = constants. normal_space;
Return response;
}
/// <Summary>
/// Obtain the DIV
/// </Summary>
/// <Param name = "iscenter"> center </param>
/// <Param name = "control"> place controls </param>
/// <Returns> </returns>
Public static htmlgenericcontrol getdiv (bool iscenter, Control)
{
Htmlgenericcontrol DIV = new htmlgenericcontrol ("Div ");
Div. enableviewstate = false;
If (iscenter)
{
Div. Attributes. Add ("align", "center ");
}
If (control! = NULL)
{
Div. Controls. Add (control );
}
Return div;
}
# Endregion

 

C # simple web development framework developed to save development information management system time and improve development efficiency

Build a basic web development framework (mainly including database processing, page framework and tools) to form a rapid development architecture of ASP. NET information management system.
I. framework implements list query and Chart Display Based on XML Customization
2. The list provides complex query conditions, merged columns (grouping and summation processing), summarized rows, and drill-through data and charts.
3. Editing and configuration supports adding and modifying data in a single table. You can easily expand the new fields in the master table on the editing page implemented by developers.
Enables developers to focus on system business implementation, saving development time and improving development efficiency

Log on to http: // 121.18.78.216/

I only spent one month on the R & D management platform you saw (only eight hours before normal operation.
Therefore, I feel that the previously developed development architecture that uses XML configuration to implement the interface enables developers to focus on business implementation and improve the development efficiency of information management systems.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.