View Full Version : Update ASP.net controls via Direct Method

Sep 13, 2010, 11:09 PM
Is it possible to update the ASP.net controls eg. TextBox, Repeater (not Coolite controls) via DirectMethod.


Sep 14, 2010, 1:54 AM

Sep 14, 2010, 5:01 AM
oops... that link above was posted to the wrong thread. Please disregard.

Sep 14, 2010, 5:10 AM
Yes, there are a couple ways to update non-Ext.NET controls during a DirectEvent/DirectMethod.

The following sample demonstrates both.

1. Getting a lite-weight "Element" instance of the Control which allows for setting of attributes of the underlying html element. The TextBox renders an <input> element, which has a "value" attribute, so calling .SetValue(...) will set this underlying "value".

2. Calling the .Update() extension method on the Control which will completely re-render the html for this specific Control. The .Update() Method can be called on any ASP.NET Control.


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

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
if (!X.IsAjaxRequest)
this.TextBox1.Text = DateTime.Now.ToLongTimeString();
this.TextBox2.Text = DateTime.Now.ToLongTimeString();

protected void Button1_Click(object sender, DirectEventArgs e)
X.Get(this.TextBox1).SetValue(DateTime.Now.ToLongT imeString());
X.Get(this.TextBox2).SetValue(DateTime.Now.ToLongT imeString());

protected void Button2_Click(object sender, DirectEventArgs e)
this.TextBox1.Text = DateTime.Now.ToLongTimeString();
this.TextBox2.Text = DateTime.Now.ToLongTimeString();

// Call .Update()

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.NET Example</title>
<form runat="server">
<ext:ResourceManager runat="server" />

<asp:TextBox ID="TextBox1" runat="server" />
<asp:TextBox ID="TextBox2" runat="server" />

<ext:Button runat="server" Text="Update TextBox1" OnDirectClick="Button1_Click" />
<ext:Button runat="server" Text="Update TextBox2" OnDirectClick="Button2_Click" />

Hope this helps.

Sep 14, 2010, 5:38 PM
In running these tests we did fix a defect with the .Update() Method. The fix has been committed to SVN and will be publicly available with the next v1.0 release.