G
GrantM
Hi,
I have created 2 controls i have created which inherit from webcontrol.
The first control is a Captcha, the second a form.
I would like to use the Captcha control in the form.
I am able to do this, but i cannot get this to Render where i want it to
render.
If i add it to the Control Collection, it will Render after the form.
If i don't add it to the Control Collection, i can get it to render where i
want, but it does not function properly.
The Init and PreRender methods of the Captcha control are not called if i
don't add it to the control collection.
Here is basically what my code looks like.
Any help on this will be greatly appreciated
1 public class CaptchaControl : WebControl, IPostBackDataHandler,
INamingContainer
2 {
3 protected override void Render(HtmlTextWriter Output)
4 {
5 //Render Control Here
6 }
7 }
8
9
10 public class FormControl : WebControl, IPostBackDataHandler,
INamingContainer
11 {
12 private CaptchaControl _captchaControl;
13
14 protected override void Render(HtmlTextWriter Output)
15 {
16 //Render start of control
17
18 _captchaControl.Render(Output); //Adding this makes the control
render twice
19
20 //Finish rendering control here
21 }
22
23 protected override void OnInit(EventArgs e)
24 {
25 base.OnInit(e);
26 if (Page != null)
27 {
28 Page.RegisterRequiresPostBack(this);
29 _captchaControl= new CaptchaControl();
30 Controls.Add(_captchaControl);
31 }
32 }
33 }
I have created 2 controls i have created which inherit from webcontrol.
The first control is a Captcha, the second a form.
I would like to use the Captcha control in the form.
I am able to do this, but i cannot get this to Render where i want it to
render.
If i add it to the Control Collection, it will Render after the form.
If i don't add it to the Control Collection, i can get it to render where i
want, but it does not function properly.
The Init and PreRender methods of the Captcha control are not called if i
don't add it to the control collection.
Here is basically what my code looks like.
Any help on this will be greatly appreciated
1 public class CaptchaControl : WebControl, IPostBackDataHandler,
INamingContainer
2 {
3 protected override void Render(HtmlTextWriter Output)
4 {
5 //Render Control Here
6 }
7 }
8
9
10 public class FormControl : WebControl, IPostBackDataHandler,
INamingContainer
11 {
12 private CaptchaControl _captchaControl;
13
14 protected override void Render(HtmlTextWriter Output)
15 {
16 //Render start of control
17
18 _captchaControl.Render(Output); //Adding this makes the control
render twice
19
20 //Finish rendering control here
21 }
22
23 protected override void OnInit(EventArgs e)
24 {
25 base.OnInit(e);
26 if (Page != null)
27 {
28 Page.RegisterRequiresPostBack(this);
29 _captchaControl= new CaptchaControl();
30 Controls.Add(_captchaControl);
31 }
32 }
33 }