Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Value of TEdit box to result of web page

Status
Not open for further replies.

firsttube

Technical User
Apr 21, 2004
165
CA
I am very new to Delphi, but I am really liking it. I have an asp page that writes some text into the response. For example:

Code:
<%
response.write("Hello")
%>

I have a delphi application with a form and a TEdit box on the form. Is there any way I can set the text in the TEdit box to be the result of the asp page. So, from the above example, the TEdit box would have "Hello" in it.

right now I have:
Code:
Edit1.Text := '[URL unfurl="true"]http://localhost/test.asp';[/URL]

but that obviously does not work.

thanks
ft


Information is not Knowledge, Knowledge is not Wisdom, Wisdom is not Truth, Truth is not Beauty, Beauty is not Love, Love is not Music, Music is the best.
 
You could use an Indy component called TIdHTTP and the following code:
Code:
var
  PostDataStream : TStringStream;
  ParamData : TStringStream;
begin
  PostDataStream := TStringStream.Create('');
  ParamData := TStringStream.Create('');
  ParamData.WriteString('username=' + Username); 
  ParamData.WriteString('&password=' + Password);
  ParamData.WriteString('&x=43');
  ParamData.WriteString('&y=8');
  try
    //Connect
    IdHttp1.Post('[URL unfurl="true"]http://localhost/test.asp',[/URL] ParamData, PostDataStream);
    Edit1.Text := PostDataStream.DataString;
  finally
    ParamData.Free;
    PostDataStream.Free;
  end;
end;
You probably don't want to pass any parameters, so I would think you could remove the ParamData variable and, in the call to IdHttp1.Post, you can probably pass nil instead of ParamData.

IdHttp1 is my TIdHTTP component which can be found in the Indy Clients page of the component toolbox.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top