Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Custom WebControl adding controls in the page

Reply
Thread Tools

Custom WebControl adding controls in the page

 
 
Galore
Guest
Posts: n/a
 
      06-03-2004
Hello,

I'm writing a custom webcontrol, and I need to make it add input hidden
controls within the tag form. Using Page.Controls.Add(control) isn't
working, it's putting the control outside the tag form, then I can't
access its data when I postback the webpage.

Does anyone here can give me a clue about this?

Thanks
 
Reply With Quote
 
 
 
 
Robert Koritnik
Guest
Posts: n/a
 
      06-03-2004
Don't use Page.Controls.Add() method. Depending on the work you shoudl
accomplich I would do it the simplest way possible and implement a compound
server control using CreateChildControls method and create your hidden
field.

You better check MSDN for that and get back for further assistance and we
will tell you which methods you really need to override.

And BTW. If your custom control won't rander anything visible (if it has
only Hidden field), that better inherit from Control class instead of
WebControl, because you don't need properties like Width, Height, Back...
blah blah blah...

--
RobertK
{ Clever? No just smart. }


"Galore" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I'm writing a custom webcontrol, and I need to make it add input hidden
> controls within the tag form. Using Page.Controls.Add(control) isn't
> working, it's putting the control outside the tag form, then I can't
> access its data when I postback the webpage.
>
> Does anyone here can give me a clue about this?
>
> Thanks



 
Reply With Quote
 
 
 
 
Galore
Guest
Posts: n/a
 
      06-03-2004
It's worked, thanks a lot!!!

[]'s

Josema wrote:

> Hi Galore,
> Maybe this can help you...
>
> class Mycustomcontrol:System.web........WebControl
> {
> protected System.Web.UI.HtmlControls.HtmlInputHidden MyHidden;
>
> protected override OnInit(EventArgs e)
> {
> InitializeComponent();
> }
> private void InitializeComponent()
> {
> MyHidden=new System.Web.UI.HtmlControls.HtmlInputHidden MyHidden;
> this.Controls.Add(MyHidden);
> }
> }
>
> this way you can add inside your control an input type hidden... then you only have to compile this webcontrol and add it into a WebForm.aspx
>
> Regards.
> Josema.
>
>
> ----- Galore wrote: -----
>
> Hello,
>
> I'm writing a custom webcontrol, and I need to make it add input hidden
> controls within the tag form. Using Page.Controls.Add(control) isn't
> working, it's putting the control outside the tag form, then I can't
> access its data when I postback the webpage.
>
> Does anyone here can give me a clue about this?
>
> Thanks
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a WebControl to a WebControl Steven ASP .Net Web Controls 1 10-13-2008 09:37 PM
databound custom controls vs composite databound custom controls rodchar ASP .Net 0 11-26-2007 03:51 PM
Custom webcontrol that references another webcontrol Fabricio ASP .Net Building Controls 0 09-21-2005 02:55 AM
Custom WebControl, custom property list Curt_C [MVP] ASP .Net Web Controls 0 09-01-2005 04:09 PM
Trapping an Exception ocurring in a Webcontrol at the Page or parent WebControl level. ASP .Net 2 01-31-2005 06:34 PM



Advertisments