2010-02-23 51 views
0

页面标记:ExtJS的窗口中显示的标记已经页面 - ASP.NET

<table style="display: none" id="myTable" runat="server"> 
    <tr> 
     <td>First Name</td> 
     <td><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td> 
    </tr> 
    <tr> 
     <td>Last Name</td> 
     <td><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td> 
    </tr> 
</table> 

我需要显示一个模态窗口和内容应该是看不见的表。创建一个窗口ExtJS的脚本如下所示:

function showWindow() { 
    var win = new Ext.Window({ 
     title: "Ext Window Example", 
     autoScroll: true, 
     modal: true, 
     html: //Here I want to use the markup of myTable 
    }); 
    win.show(); 
} 

回答

0

裹在某种容器(<div id='tableHolder' runat='server' style="display: none">...</div>)的表,请从表格样式的display: none;,然后引用容器的innerHTML在你的函数:

function showWindow() { 
    var win = new Ext.Window({ 
     title: "Ext Window Example", 
     autoScroll: true, 
     modal: true, 
     html: Ext.get('<%=tableHolder.ClientID%>').innerHTML 
    }); 
    win.show(); 
} 
+0

谢谢。我会试试这个。在我们谈论模态窗口的时候,最好的做法是在页面上包含标记,并使其在模式窗口中可见,或让模式窗口执行ajax加载,并在服务器端返回标记以显示模态? – DotnetDude 2010-02-23 19:20:34

+0

如果模态窗口的内容是静态的并且不是那么大(大取决于情况),那么我会在页面上包含标记。在其他情况下,ajax可以是用户制作更加动态的模式,并且还会加速原始页面加载和渲染时间。 – jball 2010-02-23 19:59:16