coolite 客户端对象的获取以及客户端对话框的使用

来源:互联网 发布:网络审计镜像端口 编辑:程序博客网 时间:2024/06/16 12:56

原文摘自:http://www.cnblogs.com/usee/archive/2010/08/05/1793145.html

 

现对几点内容进行增改:增改之处用红色文字显示出来

获得一个对象:
格式:#{控件的Id},
客户端使用: <ext:Button ID="Button6" runat="server" Text="获得控件对象" OnClientClick="alert(#{Button6})" >
</ext:Button> //返回一个[object,Object]对象组——"alert(#{Button6})"其中的ID大小写不区分,即也可以为button6 
修改:alert(#{Button6}.id) 返回Button6 修改:alert(#{Button6}.text) 返回 获得控件对象
服务端使用: 必须是 拼装在String里面的!必须使用string才可以使用!


控件取值、赋值的方式:
根据控件属性:
可使用 #{控件的Id}.getText() 或 #{控件的Id}.getValue() 获得控件属性值;
反之使用#{控件的Id}.setText('内容') 或 #{控件的Id}.setText('内容') 设置控件属性值;
-----------------------------------------------------------------------------------------------------
<ext:Button>控件:
<ext:Button ID="Button1" runat="server" Text="获得控件对象" OnClientClick="alert(#{Button1}.getText())" >//返回获得控件对象
        </ext:Button>
<ext:Button ID="Button1" runat="server" Text="获得控件对象" OnClientClick="#{Button1}.setText('设置控件对象内容')" >
</ext:Button> //Text="设置控件控件对象内容"
<ext:Label 控件:   #{控件的Id}.getText();             反之设置:setText('内容')
<ext:TextField 控件:   #{控件的Id}.getValue();             反之设置:setValue('内容')


客户端对话框
操作与ext 3.0相同,
alert使用:
格式:Ext.Msg.alert('标题',‘内容’,回调函数);回调函数的填写不能加引号,没有括号,没有参数,回传已经隐含了参数,只要在脚本内定义参数即可,下同
confirm使用:
格式:Ext.Msg.confirm('标题', '你想删除','回调函数');
prompt使用:
格式:Ext.Msg.prompt('title','message',callback);

 

Ext.Msg.alert函数返回值为yes,此处yes区分大小写

Ext.Msg.confirm函数返回值为yes/no,此处yes/no区分大小写

Ext.Msg.prompt函数返回值为[yes/cancle,data],data为输入的内容,可以如下showResultText回调函数给定参数


-------------------------------------------------------------------------------------------------------------------------
<script type="text/javascript">
var showResultText = function(btn, text) {
Ext.Msg.alert('Button Click', 'You clicked the ' + btn + ' button and entered the text "' + text + '".');
};

</script>

<ext:Button ID="Button3" runat="server" Text="获得控件对象" OnClientClick="Ext.Msg.prompt('Title', 'Please enter your name:',showResultText)">
</ext:Button>
---------------------------------------------------------------------------------------------------------------------------

show使用:
<ext:Button ID="Button2" runat="server" Text="获得控件对象" OnClientClick="Ext.Msg.show({title:'Save Changes?',msg: 'Would you like to save your changes?',buttons: Ext.MessageBox.YESNOCANCEL,icon: Ext.Msg.QUESTION});">
</ext:Button>