Ext.net 动态生成控件
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register Assembly="Ext.Net.UX" Namespace="Ext.Net.UX" TagPrefix="ux" %>
<script runat="server">
Ext.Net.Button b;
Ext.Net.TextField c;
protected override void OnInit(EventArgs e) {
b = new Ext.Net.Button("Get .Text");
b.DirectEvents.Click.Event += AddClick;
this.Form.Controls.Add(b);
c = new Ext.Net.TextField();
this.Form.Controls.Add(c);
}
protected void btnClick(object sender, DirectEventArgs e)
{ c.Text = "123"; }
protected virtual void AddClick(object sender, EventArgs e)
{ X.Msg.Alert("value", c.Text).Show(); }
</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 id="Head1" runat="server">
<title>Ext.Net Example</title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager runat="server" />
<ext:Button runat="server" Text="Set .Text" OnDirectClick="btnClick" />
</form>
</body>
</html>
protected override void OnInit(EventArgs e) { b = new Ext.Net.Button("Click Me"); b.ID = "myID"; b.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(AddClick); this.Form.Controls.Add(b); c = new Ext.Net.TextField(); c.ID = "edt1"; this.Form.Controls.Add(b); } protected void btnClick(object sender, DirectEventArgs e) { c.Text="123"; }