Controls for popping up MODALDIALOG for data selection

xiaoxiao2021-03-06  40

Written WebForm programs, many places need to pop up a window for data selection. The simplest case is to select the value of an HTML element directly after the pop-up window is selected, and the trouble is that the database may save is selected. The ID, so, in addition to the textbox for displaying text, there is a Hidden used to hold the ID. More terror is to select a record, and then fill the value of multiple HTML elements according to this record. Recently I wrote A control, which can be relatively universal processing.

This is a composite control, which contains a TextBox (Text corresponding control Text property) for displaying text, and a hidden TextBox for the real value of the creation of the creation (the value of the value of the TEXT corresponding to the control), and it is made with Image Button.

After the button is clicked, the JS function responsible for popping MODALDIALOG will be called. This function is specified by the clientonclick property. Then this function will be written according to the actual needs. The requirements for ModalDialog should be, click on a record, you should return a need to return a need. Custom JS objects of the attribute, the function of the Open ModalDialog is that the first parameter is incoming the IDBOX ID of the text, the second is the Hidden ID. If necessary, there is more parameters, In the form of the control, Param1, Param2 ... is incorporated. Open the window for selecting data with the showModalDioAlog function, after selecting data, give the desired value, the last function returns MODALDIALOG back Value. Although only the Name and ID properties are processed in the sample function, MODALDIALOG can return more information (such as the SEX, BIRTHDAY attribute), leave the JS function destination specified by the clientAfterClick property. Sample code is used in the sample code. Read Sex, Birthday and fill them in the corresponding TextBox

Function OpenTestWindow (DisplayID, ValueId, more) {

Var popup;

Var Offsettop = Document.getElementByid (DisplayID) .offsettop;

Var offsetleft = document.getlementByid (DisplayID) .offsetleft;

VAR PARENTELEMENT = Document.GetElementByid (DisplayID) .offsetParent;

While (pantelement) {

OFFSETTOP = Parentelement.OffSettop;

Offsetleft = Parentelement.offsetleft;

Parentelement.offSetParent;

}

Offsetleft = WINDOW.SCREENLEFT - Document.body.scrolllex;

Offsettop = WINDOW.SCREENTOP Document.getElementByid (DisplayID) .OffsetHeight - Document.body.scrolltop;

IF (! more) {

URL = '/dialogs/selectperson.aspx';

}

Else {

URL = '/dialogs/selectperson.aspx?moreperson=' more;

}

URL = ApplicationPath URL;

Popup = WINDOW.SHOWMODALDIALOG (URL,

[window],

'DialogWidth: 300px; DialogHeight: 300px; Status: 0; Dialogleft:' Offsetleft '; Dialogtop:' Offsettop; if (popup! = null) {

Document.getlementByid (DisplayID) .value = popup.name

Document.getlementByid (valueId) .value = popup.id;

Return Popup;

}

}

Control

Example

转载请注明原文地址:https://www.9cbs.com/read-62695.html

New Post(0)