Download examples and related source code
Developing ASP. NET ApplicationsProgramWriting scripts in the process is very annoying. In fact, we can pack commonly used scripts into corresponding ones.. NET component is called on the server, which can greatly simplify script writing and improve script reuse.
The following are common class calls for opening mode forms and obtaining return values. In fact, you can set multiple parameters to pass in and get different return values from different controls.
Define to open the form and set the returned value to the script class.
Hfsoft. Web. scripts. showmodaldialog dialog = new hfsoft. Web. scripts. showmodaldialog (
Xxx. Units. config. webboot + "appunit/windowopendialog. aspx ",
Frmfailurelogsearch. pageuri ());
Dialog. Height = 400;
Dialog. width = 600;
Dialog. returnelements. Add (New hfsoft.web.scripts.returnelement(this.txt return. clientid, "returnstring "));
Hfsoft. Web. scripts. registerscript. regionclick (elastic search, DIALOG );
Open the form to set the return valueCode
Hfsoft. Web. scripts. returnvalues returnvalue = new hfsoft. Web. scripts. returnvalues ();
Returnvalue. Add ("returnstring", filter );
Hfsoft. Web. scripts. registerscript. regipageclient (this, "Return", returnvalue );
Open the code of the Form class (in fact, many scripts can be encapsulated in this way ).
00006 namespace hfsoft. Web. scripts
00007
{
00008
/// <Summary>
00009
/// Create an opened form script class
00010
/// Note: the format of the data received by the return value parameter must be
00011
/// Key = value | key1 = value1 | .....
00012
/// </Summary>
00013
Public class showmodaldialog: iexecutescript
00014
{
00015
Private const string _ dialog = "window. showmodaldialog ({0},'', 'dialogheight: {1} PX;
Dialogwidth: {2} PX; edge: raised; center: Yes; help: No; resizable: No; Status: No; scroll:
Yes ;');";
00016
# Region iexecutescript Member
00017
Private bool mparent = false;
00018
/// <Summary>
00019
/// Whether the parent point needs to be loaded
00020
/// </Summary>
00021
Public boolParent
00022
{
00023
Get
00024
{
00025
// Todo: Add setelementsvalue. Parent getter implementation
00026
Return mparent;
00027
}
00028
Set
00029
{
00030
// Todo: Add setelementsvalue. Parent setter implementation
00031
Mparent = value;
00032
}
00033
}
00034
Private stringGetparent ()
00035
{
00036
If (parent)
00037
Return "parent .";
00038
Return "";
00039
}
00040
/// <Summary>
00041
/// Construct an object
00042
/// </Summary>
00043
/// <Param name = "pagecontainer"> container page </param>
00044
/// <Param name = "openpage"> page with local access </param>
00045
PublicShowmodaldialog ( StringPagecontainer , StringOpenpage )
00046
{
00047
Pagecontainer = pagecontainer;
00048
Openpage = openpage;
00049
}
00050
Public const string pageurltag = "pageurl ";
00051
/// <Summary>
00052
/// Generate the script
00053
/// </Summary>
00054
/// <Returns> string </returns>
00055
Public StringExecute ()
00056
{
00057
// Todo: Add showmodaldialog. Execute
00058
String url = "'" + pagecontainer + "? Pageurl = '+ "+ getpage ();
00059
Url = string. Format (_ dialog, URL, height, width );
00060
Url = getparent () + URL;
00061
If (returnelements. Count> 0)
00062
{
00063
Url = "Var getvalue =" + URL + "; if (getvalue! = NULL ){";
00064
Foreach (returnelement item in returnelements)
00065
{
00066
URL + = item. getscript (getparent ());
00067
}
00068
URL + = "}";
00069
Return URL + ";";
00070
}
00071
Return URL + ";";
00072
}
00073
00074
# Endregion
00075
Private string mpagecontainer;
00076
/// <Summary>
00077
/// Get or set the container page (including path)
00078
/// </Summary>
00079
Public StringPagecontainer
00080
{
00081
Get
00082
{
00083
Return mpagecontainer;
00084
}
00085
Set
00086
{
00087
Mpagecontainer = value;
00088
}
00089
}
00090
Private string mopenpage;
00091
/// <Summary>
00092
/// Open page (including path)
00093
/// </Summary>
00094
Public StringOpenpage
00095
{
00096
Get
00097
{
00098
Return mopenpage;
00099
}
00100
Set
00101
{
00102
Mopenpage = value;
00103
}
00104
}
00105
Private int mheight = 400;
00106
/// <Summary>
00107
/// Obtain or set the height of the opened form
00108
/// </Summary>
00109
Public intHeight
00110
{
00111
Get
00112
{
00113
Return mheight;
00114
}
00115
Set
00116
{
00117
Mheight = value;
00118
}
00119
}
00120
Private int mwidth = 400;
00121
/// <Summary>
00122
/// Obtain or set the width of the opened form
00123
/// </Summary>
00124
Public intWidth
00125
{
00126
Get
00127
{
00128
Return mwidth;
00129
}
00130
Set
00131
{
00132
Mwidth = value;
00133
}
00134
}
00135
Private returnelementcollections mreturnelements = new returnelementcollections ();
00136
/// <Summary>
00137
/// Obtain the returned Element Set
00138
/// </Summary>
00139
PublicReturnelementcollections returnelements
00140
{
00141
Get
00142
{
00143
Return mreturnelements;
00144
}
00145
}
00146
Private parametercollection mparameters = new parametercollection ();
00147
/// <Summary>
00148
/// Obtain the parameter set for opening the page
00149
/// </Summary>
00150
PublicParametercollection Parameters
00151
{
00152
Get
00153
{
00154
Return mparameters;
00155
}
00156
}
00157
Private stringGetpage ()
00158
{
00159
If (parameters. Count = 0)
00160
Return "'" + openpage + "'";
00161
System. Text. stringbuilder sb = new system. Text. stringbuilder ();
00162
SB. append ("'" + openpage + "'");
00163
String Param = "";
00164
String parent = getparent ();