ASP.NET页面中的Ext JS Form

时间:2012-07-22 18:31:49

标签: asp.net extjs

我在ASP.NET页面中尝试使用Ext JS 3表单,但我的表单是在" BodyContent"之外加载的。我的ASP页面。我试过了:renderTo:Ext.get(' BodyContent')但它没有用。 我的asp页面包含Ext代码:

<%@ 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(&#39; BodyContent&#39;)时,我的表单完全没有显示!!

1 个答案:

答案 0 :(得分:0)

问题是“BodyContent”不是结果页面html中的vaild id。

尝试放一个空div

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

在“BodyContent”内容占位符内部并更改表单配置以在div中进行渲染:

renderTo: 'myform'