473,382 Members | 1,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

HtmlControl or WebControl from HTML string

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

Nov 19 '05 #1
4 2820
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?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.

<mi*************@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
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

Nov 19 '05 #2
TemplateControl.ParseControl works fine in 2.0.

Check your syntax :
http://msdn2.microsoft.com/en-us/lib...l.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/
======================================
<mi*************@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
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

Nov 19 '05 #3
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

Nov 19 '05 #4
"Kevin Spencer" wrote:
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



--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.

<mi*************@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googleg roups.com...
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



--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: anthonysmales | last post by:
I have a webservice which implements a webmethod called PrettyXML. This webmethod loads an XML file and returns the XML, which is then displayed in a webcontrol (textbox) on a webform. If no XML...
0
by: Hutch | last post by:
I am looking for some thoughts on this. I have successfully gotten the HTMLControl to work using C#, and it is displaying HTML and receiving messages nicely. Unfortunately, I am not able to...
1
by: Victor | last post by:
Hi I read an article on MSDN called "Deciding When to Use the DataGrid, DataList or Repeater". It describes and compares the three web controls from the usability and performance stand point. The...
0
by: Lucas, Todd | last post by:
Hello everyone! I'm having a problem with a WebControl that I'm designing for a Menu. I've been at it for about 3 weeks now, and can't seem to get around this problem. So I'm hoping that someone...
0
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it...
0
by: Dariusz Tomon | last post by:
Hi I have got the problem with web control displaying flash (swf) object. The problem is connected with the fact that 1-st swf should loads the second one. But it doesn't. That's why I suspects...
1
by: CharlesA | last post by:
Hi folks I want to add a <ul> list with some <li> items in .net code behind on the fly I was under the impression that you could instantiate any HTML control by using the HTMLControl class...
5
by: zino | last post by:
my asp.net page need to display links (<a></a>) as tabs. I create a class that inherits from HtmlAnchor as: Public Class Tab Inherits System.Web.UI.HtmlControls.HtmlAnchor '(inheriting from...
0
by: JohnK82 | last post by:
Hi guys I have a webcontrol that displays an article in multiple parts. You can jump back and forward between the parts (I call them sheets) by clicking on a label. Each sheet has a label. The...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.