473,387 Members | 1,834 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,387 software developers and data experts.

Parsing text with code and ASP.NET

I am trying (without any luck) to find a way to parse a string and output its
processed results.

ie:

string text = "This is text from a CMS tool <asp:Label runat=\"server\"
id=\"test\" text=\"Hello World\" />";

OR

string text = "Current date is: <%=DateTime.Now.ToString() %>";

Response.Write(SomeHowEvaluateText(text));

Any ideas?

--
-Steven
May 19 '06 #1
5 1369
Steven,

It isn't entirely clear from your post exactly what the goal is, but maybe
this will help. In the first example, it looks like you are attempting to
render a declarative Label control into the Response Output stream, that
won't work at all.

In your second example you could do the following:

string text = "Current date is:" +DateTime.Now.ToString() ;

Response.Write(text);

The issue here is that declarative markup, e.g. "<asp:Label ...." is
processed when the page runs through the server. You CAN add a label control
dynamically in your codebehind, if that helps. That would be something like
(using a placeholder control):

Label lbl = new Label();
lbl.Text="This is the text";
lbl.Id="Label1";
Placeholder1.Controls.Add(lbl);

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Steven Berkovitz" wrote:
I am trying (without any luck) to find a way to parse a string and output its
processed results.

ie:

string text = "This is text from a CMS tool <asp:Label runat=\"server\"
id=\"test\" text=\"Hello World\" />";

OR

string text = "Current date is: <%=DateTime.Now.ToString() %>";

Response.Write(SomeHowEvaluateText(text));

Any ideas?

--
-Steven

May 19 '06 #2
Hi Peter,

I am not trying to programatically add controls or concatinate strings
together; rather I need to parse/evaluate ASP.NET code and render the output.

For context purposes, this is needed for a CMS-like application where the
data is stored in a DB and I want users to be able to leverage the ASP.NET
runtime.
The full field may look something like this:

string text = @"Hello world. The current date is <%=DateTime.Now%>. <br
/><br />Here is a custom control:<sb:TestControl runat=""server"" id=""test""
/>";
I want to be able to render the output of this to the page.
--
-Steven
"Peter Bromberg [C# MVP]" wrote:
Steven,

It isn't entirely clear from your post exactly what the goal is, but maybe
this will help. In the first example, it looks like you are attempting to
render a declarative Label control into the Response Output stream, that
won't work at all.

In your second example you could do the following:

string text = "Current date is:" +DateTime.Now.ToString() ;

Response.Write(text);

The issue here is that declarative markup, e.g. "<asp:Label ...." is
processed when the page runs through the server. You CAN add a label control
dynamically in your codebehind, if that helps. That would be something like
(using a placeholder control):

Label lbl = new Label();
lbl.Text="This is the text";
lbl.Id="Label1";
Placeholder1.Controls.Add(lbl);

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Steven Berkovitz" wrote:
I am trying (without any luck) to find a way to parse a string and output its
processed results.

ie:

string text = "This is text from a CMS tool <asp:Label runat=\"server\"
id=\"test\" text=\"Hello World\" />";

OR

string text = "Current date is: <%=DateTime.Now.ToString() %>";

Response.Write(SomeHowEvaluateText(text));

Any ideas?

--
-Steven

May 19 '06 #3
OK. You're talking about stuff like Virtual Path Providers, which is a new
feature in ASP.NET 2.0. Here's a link to an article that should point you in
the right direction:

http://support.microsoft.com/?id=910441

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Steven Berkovitz" wrote:
Hi Peter,

I am not trying to programatically add controls or concatinate strings
together; rather I need to parse/evaluate ASP.NET code and render the output.

For context purposes, this is needed for a CMS-like application where the
data is stored in a DB and I want users to be able to leverage the ASP.NET
runtime.
The full field may look something like this:

string text = @"Hello world. The current date is <%=DateTime.Now%>. <br
/><br />Here is a custom control:<sb:TestControl runat=""server"" id=""test""
/>";
I want to be able to render the output of this to the page.
--
-Steven
"Peter Bromberg [C# MVP]" wrote:
Steven,

It isn't entirely clear from your post exactly what the goal is, but maybe
this will help. In the first example, it looks like you are attempting to
render a declarative Label control into the Response Output stream, that
won't work at all.

In your second example you could do the following:

string text = "Current date is:" +DateTime.Now.ToString() ;

Response.Write(text);

The issue here is that declarative markup, e.g. "<asp:Label ...." is
processed when the page runs through the server. You CAN add a label control
dynamically in your codebehind, if that helps. That would be something like
(using a placeholder control):

Label lbl = new Label();
lbl.Text="This is the text";
lbl.Id="Label1";
Placeholder1.Controls.Add(lbl);

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Steven Berkovitz" wrote:
I am trying (without any luck) to find a way to parse a string and output its
processed results.

ie:

string text = "This is text from a CMS tool <asp:Label runat=\"server\"
id=\"test\" text=\"Hello World\" />";

OR

string text = "Current date is: <%=DateTime.Now.ToString() %>";

Response.Write(SomeHowEvaluateText(text));

Any ideas?

--
-Steven

May 19 '06 #4
Hi Peter,

First off, thanks for all of your assistance so far -this is definitely a
push in the right direction!

Unfortunatly I don't think this will do it for me as I do not want to serve
up virtual pages, rather, I will have an ASP.NET page (that it based off a
master page) that contains a webcontrol (think of a literal control for
simplicity sake) whos job it will be to emit the rendered content of ASP.NET
controls and code from a database table.

--
-Steven
"Peter Bromberg [C# MVP]" wrote:
OK. You're talking about stuff like Virtual Path Providers, which is a new
feature in ASP.NET 2.0. Here's a link to an article that should point you in
the right direction:

http://support.microsoft.com/?id=910441

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Steven Berkovitz" wrote:
Hi Peter,

I am not trying to programatically add controls or concatinate strings
together; rather I need to parse/evaluate ASP.NET code and render the output.

For context purposes, this is needed for a CMS-like application where the
data is stored in a DB and I want users to be able to leverage the ASP.NET
runtime.
The full field may look something like this:

string text = @"Hello world. The current date is <%=DateTime.Now%>. <br
/><br />Here is a custom control:<sb:TestControl runat=""server"" id=""test""
/>";
I want to be able to render the output of this to the page.
--
-Steven
"Peter Bromberg [C# MVP]" wrote:
Steven,

It isn't entirely clear from your post exactly what the goal is, but maybe
this will help. In the first example, it looks like you are attempting to
render a declarative Label control into the Response Output stream, that
won't work at all.

In your second example you could do the following:

string text = "Current date is:" +DateTime.Now.ToString() ;

Response.Write(text);

The issue here is that declarative markup, e.g. "<asp:Label ...." is
processed when the page runs through the server. You CAN add a label control
dynamically in your codebehind, if that helps. That would be something like
(using a placeholder control):

Label lbl = new Label();
lbl.Text="This is the text";
lbl.Id="Label1";
Placeholder1.Controls.Add(lbl);

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Steven Berkovitz" wrote:

> I am trying (without any luck) to find a way to parse a string and output its
> processed results.
>
> ie:
>
> string text = "This is text from a CMS tool <asp:Label runat=\"server\"
> id=\"test\" text=\"Hello World\" />";
>
> OR
>
> string text = "Current date is: <%=DateTime.Now.ToString() %>";
>
> Response.Write(SomeHowEvaluateText(text));
>
> Any ideas?
>
> --
> -Steven

May 19 '06 #5
You could still use a custom Virtual Path Provider for this. Providers can
also be chained, so if something isn't found, it would fallback to th
Previous (the default) provider. If you have stuff coming out of a database,
this could be the way to go because it gives you the ability to store
user-specific code and controls in a database table column / row and key off
of something like a querystring item.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Steven Berkovitz" wrote:
I am trying (without any luck) to find a way to parse a string and output its
processed results.

ie:

string text = "This is text from a CMS tool <asp:Label runat=\"server\"
id=\"test\" text=\"Hello World\" />";

OR

string text = "Current date is: <%=DateTime.Now.ToString() %>";

Response.Write(SomeHowEvaluateText(text));

Any ideas?

--
-Steven

May 21 '06 #6

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

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
2
by: Rashida | last post by:
Hi all! I have written a function to fetch lebels from xml file for cross-language interoperability. Please refer function code below. I am invoking itfrom my asp page saying...
7
by: Lucas Tam | last post by:
Hi all, Does anyone know of a GOOD example on parsing text with text qualifiers? I am hoping to parse text with variable length delimiters/qualifiers. Also, qualified text could run onto...
4
by: Earl | last post by:
I'm curious if there are others who have a better method of accepting/parsing phone numbers. I've used a couple of different techniques that are functional but I can't really say that I'm totally...
2
by: JaythePCguy | last post by:
Hi, I am trying to write a text parser to group all nonprintable and control characters, spaces and space delimited words in different groups using Regex class. Using a parsing of...
9
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
1
by: martinsson | last post by:
Hi all! I'm pretty mad about this... dont know what is going on. Im parsing XML file that looks like this: <something> __<item att="something">text<item> __<item...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.