Your question is confusing. First, what do you mean by "get?" Second, a
Control is a class. A string is text. So, what exactly are youre
requirements?

Signature
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
A watched clock never boils.
> Hello,
>
[quoted text clipped - 4 lines]
> CIAO
> Michael
Michael - 29 Oct 2005 15:41 GMT
>Your question is confusing. First, what do you mean by "get?" Second, a
>Control is a class. A string is text. So, what exactly are youre
>requirements?
I get a string like "<select><option value=1>One</option></select>" and
want to get a HtmlSelect control. In .NET 1.1 I used this code:
TemplateControl p = new System.Web.UI.UserControl();
Control htmlControl = p.ParseControl("<select
runat=\"server\"><option>hans</option></select>");
HtmlControl result = null;
if (htmlControl.GetType() == htmlControlType)
{
result = htmlControl as HtmlControl;
}
else
{
foreach (Control con in htmlControl.Controls)
{
if (con.GetType() == htmlControlType)
{
result = con as HtmlControl;
break;
}
}
}
In .NET 2.0 I get an exception that the property virtualPath is missing.
If I use the ParseControl method in a webform (UI.Page) it is working
correct, but I need this code in a library.
Regards,
Michael
>> Hello,
>>
[quoted text clipped - 4 lines]
>> CIAO
>> Michael
--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
TemplateControl.ParseControl works fine in 2.0.
Check your syntax :
http://msdn2.microsoft.com/en-us/library/system.web.ui.templatecontrol.parsecontrol
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
> Hello,
>
[quoted text clipped - 4 lines]
> CIAO
> Michael
michael.schwarz@gmail.com - 29 Oct 2005 15:42 GMT
The problem is that I need this feature in a library, not on a page. I
get the error ArgumentException for argument virtualPath.
CIAO
Michael