Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

HtmlControl or WebControl from HTML string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
michael.schwarz@gmail.com - 29 Oct 2005 00:00 GMT
Hello,

is it possible to get a HtmlControl from a string including the HTML
code in .NET 2.0? I was using the TemplateControl.ParseControl method
in .NET 1.1, but this is not working in the new version.

CIAO
Michael
Kevin Spencer - 29 Oct 2005 00:06 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?

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
Juan T. Llibre - 29 Oct 2005 00:14 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.