Retrieve textFiled Id from parent view within child view

  1. #1

    Retrieve textFiled Id from parent view within child view

    Hello,
    I implemented a view that contains a textField and a button, when I click on the button a Window will be appear, the window contains a textfield implemented pragmatically I would like to retrieve the id of the textfield implemented in parent window I get this error :
    Ext is not defined
    This is my controller contains two actions : the first one generate textFiled and the second one load the textField to the view :
        public class ResearchController : Controller
        {
      [HttpGet]
            public ActionResult Research()
            {
                return View();
            }
    
            [HttpGet]
            public ActionResult ViewPage1()
            {
                return View();
            }
    
          public ContentResult LoadViewPage1Content(String containerID)
            {
                ContentResult contentResult = new ContentResult();
                contentResult.Content = string.Format(
                    "<script>{0}</script>",
                  GenerateTxt()
                    .ToScript(
                    RenderMode.AddTo,
                    containerID));
                return contentResult;
            }
    
            [NonAction]
            public TextField GenerateTxt()
            {
                TextField txt = new TextField();
                txt.ID = "_test";
                txt.FieldLabel = "Txt";
                return txt;
            }
    }
    This is the parent View called [Research.aspx]
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.Net.MVC Example</title>
        <script type="text/javascript">
            var onClick = function () {
                var window = win;
                window.show();
            };
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Button runat="server" Icon="Find" ID="btn">
            <Listeners>
                <Click Handler="onClick();" />
            </Listeners>
        </ext:Button>
        <ext:TextField runat="server" FieldLabel="txt" ID="_txt">
        </ext:TextField>
        <ext:Window ID="win" runat="server" Icon="ApplicationForm" Width="800" Height="600"
            Modal="true" Constrain="true" Hidden="true">
            <AutoLoad Url="/Research/ViewPage1" Mode="IFrame" TriggerEvent="show" ReloadOnEvent="true"
                ShowMask="true" MaskMsg="Loading ...">
            </AutoLoad>
        </ext:Window>
        </form>
    </body>
    </html>
    This Child View Called [ViewPage1.aspx]
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.Net.MVC Example</title>
        <script type="text/javascript">
            console.log(Ext.getCmp('_txt'));
        </script>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <form id="Form1" runat="server">
        </form>
        <ext:Panel ID="_pnl" runat="server" Border="false" Header="false">
            <AutoLoad Url="/Research/LoadViewPage1Content">
                <Params>
                    <ext:Parameter Name="containerID" Value="#{_pnl}" Mode="Value" />
                </Params>
            </AutoLoad>
        </ext:Panel>
    </body>
    </html>
  2. #2
    Quote Originally Posted by wadhah View Post
    Hello,
    I implemented a view that contains a textField and a button, when I click on the button a Window will be appear, the window contains a textfield implemented pragmatically I would like to retrieve the id of the textfield implemented in parent window I get this error :
    Ext is not defined
    This is my controller contains two actions : the first one generate textFiled and the second one load the textField to the view :
        public class ResearchController : Controller
        {
      [HttpGet]
            public ActionResult Research()
            {
                return View();
            }
    
            [HttpGet]
            public ActionResult ViewPage1()
            {
                return View();
            }
    
          public ContentResult LoadViewPage1Content(String containerID)
            {
                ContentResult contentResult = new ContentResult();
                contentResult.Content = string.Format(
                    "<script>{0}</script>",
                  GenerateTxt()
                    .ToScript(
                    RenderMode.AddTo,
                    containerID));
                return contentResult;
            }
    
            [NonAction]
            public TextField GenerateTxt()
            {
                TextField txt = new TextField();
                txt.ID = "_test";
                txt.FieldLabel = "Txt";
                return txt;
            }
    }
    This is the parent View called [Research.aspx]
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.Net.MVC Example</title>
        <script type="text/javascript">
            var onClick = function () {
                var window = win;
                window.show();
            };
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Button runat="server" Icon="Find" ID="btn">
            <Listeners>
                <Click Handler="onClick();" />
            </Listeners>
        </ext:Button>
        <ext:TextField runat="server" FieldLabel="txt" ID="_txt">
        </ext:TextField>
        <ext:Window ID="win" runat="server" Icon="ApplicationForm" Width="800" Height="600"
            Modal="true" Constrain="true" Hidden="true">
            <AutoLoad Url="/Research/ViewPage1" Mode="IFrame" TriggerEvent="show" ReloadOnEvent="true"
                ShowMask="true" MaskMsg="Loading ...">
            </AutoLoad>
        </ext:Window>
        </form>
    </body>
    </html>
    This Child View Called [ViewPage1.aspx]
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.Net.MVC Example</title>
        <script type="text/javascript">
            console.log(Ext.getCmp('_txt'));
        </script>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <form id="Form1" runat="server">
        </form>
        <ext:Panel ID="_pnl" runat="server" Border="false" Header="false">
            <AutoLoad Url="/Research/LoadViewPage1Content">
                <Params>
                    <ext:Parameter Name="containerID" Value="#{_pnl}" Mode="Value" />
                </Params>
            </AutoLoad>
        </ext:Panel>
    </body>
    </html>
    Solved I should use
    parent._txt
    to retrive textField ID.

Similar Threads

  1. Replies: 1
    Last Post: May 29, 2012, 8:51 AM
  2. Replies: 2
    Last Post: Jan 10, 2012, 6:35 AM
  3. [CLOSED] Partial View Hiding Toolbar on Parent
    By GLD in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 12, 2011, 7:31 PM
  4. Replies: 16
    Last Post: Jul 19, 2011, 3:53 AM
  5. Switch from tree view to accordian view?
    By jaydwire2 in forum 1.x Help
    Replies: 1
    Last Post: Sep 18, 2009, 4:31 PM

Posting Permissions