2012-07-22 61 views
0

我正在ASP.NET頁面中嘗試一個Ext JS 3表單,但我的表單在我的ASP頁面的「BodyContent」之外加載。我試過:renderTo:Ext.get('BodyContent')但它不工作。 我與分機代碼ASP頁:在ASP.NET頁面中的Ext JS表格

<%@ Page Title="Forms" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" 
    CodeBehind="Forms.aspx.cs" Inherits="ExtJSDemo.Forms" %> 

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> 
    <link rel="stylesheet" type="text/css" href="ext-3.4.0/resources/css/ext-all.css" /> 
    <script type="text/javascript" src="ext-3.4.0/adapter/ext/ext-base.js"></script> 
    <script type="text/javascript" src="ext-3.4.0/ext-all-debug.js"></script> 
    <script type="text/javascript"> 
     if (Ext.BLANK_IMAGE_URL.substr(0, 5) != 'data:') { 
      Ext.BLANK_IMAGE_URL = 'ext-3.4.0/resources/images/default/s.gif'; 
     } 
     Ext.onReady(function() { 
      var movie_form = new Ext.FormPanel({ 
       url: 'movie-form-submit.aspx', 
       renderTo: Ext.getBody(), 
       frame: true, 
       title: 'Movie Information Form', 
       width: 250, 
       items: [{ 
        xtype: 'textfield', 
        fieldLabel: 'Title', 
        name: 'title' 
       },{ 
        xtype: 'textfield', 
        fieldLabel: 'Director', 
        name: 'director' 
       },{ 
        xtype: 'datefield', 
        fieldLabel: 'Released', 
        name: 'released' 
       }] 
      }); 
     }); 
    </script> 

</asp:Content> 
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> 
<!-- I'M EXPECTING MY FORM HERE, BUT IT'S LOADED OUTSIDE BodyContent AT THE BOTTOM OF THE ENTIRE PAGE --> 
</asp:Content> 

當我使用renderTo:Ext.get(「的BodyContent」)完全不顯示我的狀態!

回答

0

問題是「BodyContent」不是結果頁面html中的vaild id。

嘗試把一個空div

<div id="myform"></div> 

內 「的BodyContent」 內容佔位符和變化的形式配置到DIV中呈現:

renderTo: 'myform'

+0

謝謝馬爾科,它的工作原理:) – Stacked 2012-07-22 18:47:06