Webcontrols!!

  • Thread starter Victor Rodriguez
  • Start date
V

Victor Rodriguez

Is there a way to get the code produced from adding controls to a page and
child controls to them from code?

like if by vb code i insert mycontrol.controls.add(newcontrol) and get the
<ex:mycontrol><ex:child><ex:child></ex:mycontrol>

is that possible?

Victor
 
L

Lewis Wang [MSFT]

Hi Victor,

I don't think it's possible. When we use a web user control in a web form,
it should be a unit control not a container. So, we can't add innerhtml
between <ex:mycontrol> and </ ex:mycontrol>.

ControlCollection.Add method is used for adding child controls dynamically
and it does not generate any code in *.aspx.

Does this answer your question? Please let me know if you need more
information

Best regards,
Lewis
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "Victor Rodriguez" <[email protected]>
| Subject: Webcontrols!!
| Date: Sun, 7 Sep 2003 01:27:12 -0500
| Lines: 11
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: adsl-66-136-72-237.dsl.rcsntx.swbell.net 66.136.72.237
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:14451
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Is there a way to get the code produced from adding controls to a page and
| child controls to them from code?
|
| like if by vb code i insert mycontrol.controls.add(newcontrol) and get the
| <ex:mycontrol><ex:child><ex:child></ex:mycontrol>
|
| is that possible?
|
| Victor
|
|
|
 
V

Victor Rodriguez

No it does not asnwer my question.

I know there has to be some way to do it because when you have like a
treeview control and you add treenodes with the form for editing properties
it does write the aspx code on the page. I would like to figure that out
because it'll be very usefull.

Victor
 
L

Lewis Wang [MSFT]

Hi Victor,

It's right that we can get: <tvns:treeview . . .><tvns:treenode
Selected="true">good</tvns:treenode></tvns:treeview> on the client side if
we use TreeView1.Nodes.Add(node). However IE Treeview control is a custom
control not a user control. So, we can not achieve the same result using
mycontrol.controls.add(newcontrol).

To workaround this issue, we can add all controls to a ArrayList. Then we
could override void Render(System.Web.UI.HtmlTextWriter writer) in
*.ascx.cs and render all controls in the ArrayList by ourselves. Something
like this:

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
. . .
StringWriter sw;
System.Web.UI.HtmlTextWriter htmltw;
sw = new StringWriter();
htmltw = new System.Web.UI.HtmlTextWriter (sw);
base.Render(htmltw);
StringBuilder temp = sw.GetStringBuilder();
temp.Append("<INPUT type="button" value="Button">");//render a button;
writer.Write(temp);
. . .
}

We can also check the source code of the TreeView(treenode.cs,
treenodetypecollection.cs, treeview.cs) to achieve this in a similar way.
//We can extract IEWebControls.exe to get all source code of IE Web
Controls.

Hope this helps.

Best regards,
Lewis
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "Victor Rodriguez" <[email protected]>
| References: <#[email protected]>
<#[email protected]>
| Subject: Re: Webcontrols!!
| Date: Mon, 8 Sep 2003 09:27:49 -0500
| Lines: 64
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: adsl-66-141-108-169.dsl.rcsntx.swbell.net
66.141.108.169
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:14471
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| No it does not asnwer my question.
|
| I know there has to be some way to do it because when you have like a
| treeview control and you add treenodes with the form for editing
properties
| it does write the aspx code on the page. I would like to figure that out
| because it'll be very usefull.
|
| Victor
|
|
| | > Hi Victor,
| >
| > I don't think it's possible. When we use a web user control in a web
form,
| > it should be a unit control not a container. So, we can't add innerhtml
| > between <ex:mycontrol> and </ ex:mycontrol>.
| >
| > ControlCollection.Add method is used for adding child controls
dynamically
| > and it does not generate any code in *.aspx.
| >
| > Does this answer your question? Please let me know if you need more
| > information
| >
| > Best regards,
| > Lewis
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| >
| > --------------------
| > | From: "Victor Rodriguez" <[email protected]>
| > | Subject: Webcontrols!!
| > | Date: Sun, 7 Sep 2003 01:27:12 -0500
| > | Lines: 11
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Message-ID: <#[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | NNTP-Posting-Host: adsl-66-136-72-237.dsl.rcsntx.swbell.net
| 66.136.72.237
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.webcontrols:14451
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > |
| > | Is there a way to get the code produced from adding controls to a page
| and
| > | child controls to them from code?
| > |
| > | like if by vb code i insert mycontrol.controls.add(newcontrol) and get
| the
| > | <ex:mycontrol><ex:child><ex:child></ex:mycontrol>
| > |
| > | is that possible?
| > |
| > | Victor
| > |
| > |
| > |
| >
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,104
Latest member
LesliVqm09
Top