[CLOSED] Update ASP.Net Controls during DirectEvent/Method
I am trying to update an ASP.Net control during a direct event but it is not working. I am trying to use this example below but none of my ASP.Net controls have an "Update()" method.
Code:
<%@ Page Language="C#" %>
<%@ 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 runat="server">
<title></title>
<script runat="server">
protected void UpdateTextBox(object sender, DirectEventArgs e)
{
TextBox1.Text = string.Empty;
TextBox1.Update();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<asp:TextBox ID="TextBox1" runat="server" Text="Text" />
<ext:Button runat="server" Text="Clear">
<DirectEvents>
<Click OnEvent="UpdateTextBox" />
</DirectEvents>
</ext:Button>
</form>
</body>
</html>
RE: [CLOSED] Update ASP.Net Controls during DirectEvent/Method
Hi alexkay,
Thanks for the clean sample, although when I test, the <asp:TextBox> appears to be updated correctly during the DirectEvent.
I modified your sample slightly. Try the following.
Example
Code:
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void UpdateTextBox(object sender, DirectEventArgs e)
{
this.TextBox1.Text = DateTime.Now.ToLongTimeString();
this.TextBox1.Update();
}
</script>
<!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 runat="server">
<title>Ext.NET Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<asp:TextBox ID="TextBox1" runat="server" Text="Text" />
<ext:Button runat="server" Text="Clear" OnDirectClick="UpdateTextBox" />
</form>
</body>
</html>
Hope this helps.
RE: [CLOSED] Update ASP.Net Controls during DirectEvent/Method
Ok, I figured it out, the update method is an extension method, you have to include the namespace Ext.Net in your code to get it to work.
RE: [CLOSED] Update ASP.Net Controls during DirectEvent/Method
Thanks, Geoeffrey,
The main thing i was missing was the namespace, without it the update method did not exist and the code would not compile.