Click to See Complete Forum and Search --> : Is there an ASP.NET equivalant to PHP's 'echo'?


cube01
June 20th, 2008, 10:32 AM
Thats it. Just need to know if ASP.NET has something similiar to the 'echo' command in PHP so I can programatically insert html into my page.

For example in PHP I can do this:
<?php echo "<p> I am echoing this text.</p>"; } ?>

I know there are better ways to show a text string, I'm just using that as an example ;-)


Thanks in advance!

hspc
June 20th, 2008, 11:42 AM
You can use Response.Write() method. But why do you want to echo text directly? Why not use asp.net controls?

cube01
June 20th, 2008, 02:06 PM
Specifically, I need to open a pop up window. However the content of the popup will vary based on user input. Since I can't use C# to open the pop-up, I was going to use Javascript and "echo" the appropriate url into it.
Any suggestions?

Thanks again.

hspc
June 21st, 2008, 05:15 AM
You open the windows using javascript, that's ok. but the popup page is still an aspx page, it can check the query string and set the text of label controls.

cube01
June 21st, 2008, 10:43 AM
Thats a good point. Thanks.
But how do I pass the dynamically created URL to the html code that I'm using to open the popup?
Thanks again.

TheCPUWizard
June 21st, 2008, 11:56 AM
You either:

1) Dynaqmically Inject the JavaScript from your C# code.
2) You use the AJAX libraries to manage this for you.

cube01
June 21st, 2008, 02:42 PM
Roger, but how do I use my C# variable in my ASP code? Thats all I really need to do.

Thanks again. I appreciate the help.

TheCPUWizard
June 21st, 2008, 03:58 PM
Roger, but how do I use my C# variable in my ASP code? Thats all I really need to do.

Thanks again. I appreciate the help.

You are still thinking "backwards".

Pseudo-

string s = String.Format("This is SomeJavaScript {0} With Variable Contents", var);
"InjectScript"(s);

cube01
June 21st, 2008, 09:11 PM
Got it. Thanks for the help. It's appreciated!