Oct 20, 2010, 1:04 AM
[CLOSED] How to get the control ID after I using "Control2.Render(Control1,RenderMode.AddTo)"?
First you had helped me to resolve the problem:
http://forums.ext.net/showthread.php?10547-CLOSED-How-to-get-the-control-ID-after-I-using-quot-Control2.Render(Control1-RenderMode.AddTo)-quot
But when I want to check the control in another Button Event, it was failed again:
So please help me to check the code , thanks.
(I want to get the control in another event CheckControl())
http://forums.ext.net/showthread.php?10547-CLOSED-How-to-get-the-control-ID-after-I-using-quot-Control2.Render(Control1-RenderMode.AddTo)-quot
But when I want to check the control in another Button Event, it was failed again:
So please help me to check the code , thanks.
(I want to get the control in another event CheckControl())
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default6.aspx.cs" Inherits="Default6" %>
<%@ 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>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Panel ID="PanelsCt" runat="server" AutoHeight="true" Title="Panels container">
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="Button1" runat="server" Text="Add">
<DirectEvents>
<Click OnEvent="AddNewItem">
</Click>
</DirectEvents>
</ext:Button>
<ext:Button ID="Button2" runat="server" Text="Check">
<DirectEvents>
<Click OnEvent="CheckControl">
</Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:Panel>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
public partial class Default6 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void AddNewItem(object sender, DirectEventArgs e)
{
Ext.Net.TextField t = new Ext.Net.TextField
{
ID = "t1",
Width = Unit.Pixel(200)
};
t.Text = t.ID;
Toolbar1.Items.Add(t);
t.Render();
if (Page.FindControl("t1") != null)
{
X.Msg.Alert("", "Yes, find!").Show(); // ->Succeed
}
else
{
X.Msg.Alert("", "No, Sorry!").Show();
}
}
protected void CheckControl(object sender, DirectEventArgs e)
{
if (Page.FindControl("t1") != null)
{
X.Msg.Alert("", "Yes, find!").Show(); // ->Fail
}
else
{
X.Msg.Alert("", "No, Sorry!").Show();
}
}
}
Last edited by Daniil; Oct 21, 2010 at 2:23 PM.
Reason: [CLOSED]