JavaScript does not need to be compiled to run, which allows JavaScript-built applications to become flexible. We can dynamically load JavaScript scripts from the server as needed to create and control the UI to interact with the user. The following combination of Ext JS to explain how to dynamically load JS script from the server to create the form dynamically.
1 Project Structure:
the project structure is as follows: The Getjsui general handler is used to crawl the UI configuration from the database table and return it to the client; Contents folder with HTML files and JS library.
2 database table structure
You can create a table in MSSQL with the following SQL, where the Javascriptcontent field stores the specific JS script.
CREATE TABLE [dbo]. [Ext_dynamic_form] (
[ID] [nvarchar] (m) not NULL,
[uniname] [nvarchar] null,
[javascriptcontent] [nvarchar] (4000) NULL,
[Memo] [nvarchar] () NULL,
CONSTRAINT [Pk_ext_dynamic_form] PRIMARY KEY CLUSTERED
(
[ID] ASC
)
) on [PRIMARY]
Once created, you can initialize the data:
Once created, you can initialize the data:
4 Getjsui Programming
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using Cmclouddbhelper;
Namespace EXTJS6. Services
{
///<summary>
///author:jackwangcumt
///</summary> Public
class Getjsui:ihttphandler
{public
void ProcessRequest (HttpContext context)
{
string js = "";
Context. Response.ContentType = "Text/plain";
Context. Response.ContentType = "Text/javascript";
Cmcdataaccess da = new cmcdataaccess ();
String Sqlforjs = "SELECT * from Ext_dynamic_form where id= ' 006 '";
System.Data.DataTable dt= da. Getdatatable (SQLFORJS);
if (dt!=null)
{
if (dt). Rows.count==1)
{
js = dt. rows[0]["Javascriptcontent"]. ToString ();
}
}
Utf-8 context
. response.contentencoding = System.Text.Encoding.UTF8;
Context. Response.Write (JS);
}
public bool IsReusable
{
get
{return
false;
}}}
5 Main interface HTML
6 run
So we can do a main framework, and then build a common system such as menus and permissions, through the configuration of the database menu and UI, can dynamically expand the application.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.