View Full Version : [CLOSED] Set Textfield from static DirectMethod

Nov 14, 2012, 8:11 PM
What is the best way to set a textfield from a static DirectMethod? I understand that the static Direct Method does not have access to the Page controls.

Nov 14, 2012, 8:14 PM
Correct. During a Static [DirectMethod] you do not have access to the Page Controls Collection, so no direct access to a TextField. But, by using the X.GetCmp helper Method you can get an instance (more like a proxy instance) of the component.

The following sample demonstrates the complete scenario.


<%@ Page Language="C#" %>

<script runat="server">
public static void DoSomething()
var textfield = X.GetCmp<TextField>("TextField1");

textfield.Text = "Testing";

<!DOCTYPE html>

<head runat="server">
<title>Ext.NET Example</title>
<ext:ResourceManager runat="server" />

<ext:TextField ID="TextField1" runat="server" />

<ext:Button runat="server" Text="Submit">
<Click Handler="App.direct.DoSomething();" />

Hope this helps.

Nov 14, 2012, 9:39 PM
Thanks Geoffrey, that works!