Feb 01, 2012, 9:28 AM
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 :
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>