Ext牛人进
我用载入模板页的页面控制EXt控件总是出问题,具体代码如下:
说明:我在后台执行javascript代码弹出的是undefined
<%@ Page Title="" Language="C#" MasterPageFile="~/Talent/ReservePool.master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Morpheus.Web.Talent.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderHead" runat="server">
<script src="../Scripts/Talent/TalentDetailList.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderContent" runat="server">
<ext:Button ID="test1" runat="server" Text="test">
<DirectEvents>
<Click OnEvent="Test_Click"></Click>
</DirectEvents>
</ext:Button>
<script type="text/javascript">
function testFun() {
var testbtn = Ext.getCmp("test1");
alert(testbtn);
}
</script>
</asp:Content>
------解决方案--------------------浏览网页时右键看下控件的ID。应该会加上一个前辍了!所以找不到test1 ID的这个控件
------解决方案--------------------<script type="text/javascript">
function testFun() {
var testbtn = Ext.getCmp(
<%=test1.ClientID%>);
alert(testbtn);
}
</script>
------解决方案-------------------- var testbtn = Ext.getCmp("test1");
=>
var testbtn = Ext.getCmp("<%=test1.ClientID%>");