Ext.Net 中TextField的KeyPress及Value的处理【总结】
(1)TextField 中KeyPress 事件:
<ext:TextField
ID="txtCon"
runat="server"
LabelAlign ="Right"
FieldLabel ="con"
Width ="250px"
Height="25px"
EnableKeyEvents="true"
>
<Listeners>
<KeyPress Handler="if (e.getKey()==Ext.EventObject.ENTER){Ext.net.DirectMethods.TextKeyPress();e.stopEvent();}" />
<%--<SpecialKey Handler="alert('You pressed on the \'special\' key with code ' + e.getKey())" />--%>
</Listeners>
</ext:TextField>
(2)由ID Set TextField 的值:
X.GetCmp<TextField>(“TextFieldID”).Text =newValue; //如上::TextFieldID=“txtcon”
或者是使用javascript :
<script type="text/javascript">
function ClearPanelItemJS(ctrlids_str,Value_Str)
{
if (ctrlids_str != null && ctrlids_str.length > 0)
{
var ctrlids = ctrlids_str.split(';');
var value=Value_Str.split(';');
for (i=0; i<ctrlids.length; i++)
{
var ctrl = document.getElementById(ctrlids[i]);
if (ctrl != null) ctrl.value = value[i];
};
}
}
</script>
在Server端Event中添加 :X.ResourceManager.AddScript("ClearPanelItemJS('" + ctrlids + "',"+value+");"); //传递ID,Value参数