Stumped

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Do you know how to replace a string in a SreamReader with a dynamically
created control such as a textbox that can be runat=server?

I am trying to read in a file and replace certain key words with objects
that I can then collect data from via postback. Any ideas?
 
Do you know how to replace a string in a SreamReader with a dynamically
created control such as a textbox that can be runat=server?

I am trying to read in a file and replace certain key words with objects
that I can then collect data from via postback. Any ideas?

I believe you'll need to convert the string back into a string, because
..NET's replace function doesn't use an IO stream :(
 
Thanks Lucas - lets say I have the following:

Dim strTemp as String = "Please type your name: {text}"

How could I replace {text} with a textbox that I can access during postback?
 
Thanks Lucas - Lets say I have the following:

Dim strTemp as String = "Please enter your name: {text}"

How could I replace the {text} portion above with a textbox that I could
access during postback?
 
You can output HTML, but you cannot output anything that can be processed by
the server. The reason being that by the time your search/replace code
runs, it has already loaded all server control into memory and all you can
do is either create new control objects and add them to the Controls
collection or output HTML content such as <input type="submit" ...>
 
if it is HTML text box, that is simple

strTemp.replace("{text}","<input name=text1 type=text />");

you could access this by Request.Forms("text1") during post back.

if you need web controls, then i guess the only way is to dynamically
create controls if {text} is found in the string

if (strTemp.indexOf("{text}" > -1)
{
// create new label and assign text 'Please enter your name:'
// create new text box
Label label1 = new Label();
label1.Text = "Please enter your name:";
TextBox txt1 = new TextBox();
txt1.ID = "txt1";
}

Not sure if this is what you are looking for...
 

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

Back
Top