sbornstein2
asked on
C# Class Question
Good Morning All,
I have a basic question that should be pretty easy. I have a class file that is a WebControl class file and in the OnInit I create a window object it is a telerik control RadWindow. So that RadWindow has a ContentTemplate which is a ITemplate that I had to create a seperate class and use the ITemplate interface such as System.Web.UI.ITemplate. In the instantiate of that I have all content controls I need etc. I have a button in this template that has to go into the contenttemplate so it needs to exist here. On the OnClick event handler I need to call the RadWindow property to close it RadWindow.VisibleOnPageLoa d = false. Stupid question is how do I call that from within the ITemplate when it is being created on the OnInit of my main class? I tried doing such as this in the close button event:
MyMainClass mycls = new MyMainClass();
mycls.RadWindow1.VisibleOn PageLoad = false
but I am getting NULL for that RadWindow1 when I do this so I know it is the new I beleive. Thanks all not sure why this is confusing me.
I have a basic question that should be pretty easy. I have a class file that is a WebControl class file and in the OnInit I create a window object it is a telerik control RadWindow. So that RadWindow has a ContentTemplate which is a ITemplate that I had to create a seperate class and use the ITemplate interface such as System.Web.UI.ITemplate. In the instantiate of that I have all content controls I need etc. I have a button in this template that has to go into the contenttemplate so it needs to exist here. On the OnClick event handler I need to call the RadWindow property to close it RadWindow.VisibleOnPageLoa
MyMainClass mycls = new MyMainClass();
mycls.RadWindow1.VisibleOn
but I am getting NULL for that RadWindow1 when I do this so I know it is the new I beleive. Thanks all not sure why this is confusing me.
ASKER
Well the RadWindow1 initlaization is happening actually in the OnInit because it is a WebControl
public RadWindow RadWindow1;
protected override void OnInit(EventArgs e)
{
RadWindow1 = new RadWindow();
}
public RadWindow RadWindow1;
protected override void OnInit(EventArgs e)
{
RadWindow1 = new RadWindow();
}
ASKER
then how should I call it in my other class?
OnInit of you UserControl will be called only when the control start rendered, So to access the control it's to be initialized first.
Nothing changing in call the control, it's matter of initialization.
Nothing changing in call the control, it's matter of initialization.
ASKER
I have to have the RadWindow in the OnInit though of the WebControl here is what I have:
public class MyControl : WebControl
{
public RadWindow RadWindow1;
private ContentInnerTemplate cntTemplate = new ContentInnerTemplate();
protected override void OnInit(EventArgs e)
{
RadWindow1 = new RadWindow();
RadWindow1.ContentTemplate = cntTemplate;
this.controls.add(RadWindo w1)
}
}
I had to customize the contenttemplate so now the template is:
public class ContentInnerTemplate : System.Web.UI.ITemplate
{
public void InstantiateIn(System.Web.U I.Control container)
{
RadButton rbtnDone = new RadButton();
rbtnDone.Click += new EventHandler(rbtnDone_Clic k);
container.Add(rbtnDone);
}
protected void rbtnDone_Click(object sender, EventArgs e)
{
//THIS IS WHERE I WANT TO CALL THE RADWINDOW1 CLOSE
RadWindow1.VisiblePageLoad = false;
}
}
public class MyControl : WebControl
{
public RadWindow RadWindow1;
private ContentInnerTemplate cntTemplate = new ContentInnerTemplate();
protected override void OnInit(EventArgs e)
{
RadWindow1 = new RadWindow();
RadWindow1.ContentTemplate
this.controls.add(RadWindo
}
}
I had to customize the contenttemplate so now the template is:
public class ContentInnerTemplate : System.Web.UI.ITemplate
{
public void InstantiateIn(System.Web.U
{
RadButton rbtnDone = new RadButton();
rbtnDone.Click += new EventHandler(rbtnDone_Clic
container.Add(rbtnDone);
}
protected void rbtnDone_Click(object sender, EventArgs e)
{
//THIS IS WHERE I WANT TO CALL THE RADWINDOW1 CLOSE
RadWindow1.VisiblePageLoad
}
}
ASKER
I have to have the Done button in the contenttemplate of the RadWindow in order to be able to get at the button.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
e,g
class MyMainClass
{
public RadWindow RadWindow1;
public MyMainClass ()
{
RadWindow1 = new RadWindow();
}
}
try with the above syntax