I have the following, which reads an html file from a different server, then displays it on the page in a label.
The html it returns includes an image tag with a relative src attribute, like: <img src="2343.jpg">
What I need to do is insert the local path into this src attribute so the image will display in the output... so it should end up like this: <img src="../whateverDirectory/2343.jpg">
Can anyone show me how this can be done? Is there a way to read/replace or something like that?
Thanks!
Code:
protected void Page_Load(object sender, EventArgs e)
{
string thePartNo;
thePartNo = Request.QueryString["part_no"];
txtURL.Text = "[URL unfurl="true"]http://www.domainname.com/supplierstaging/123/"[/URL] + thePartNo.ToString() + "info.htm";
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
// Create a WebRequest
WebRequest wrRequest;
wrRequest = WebRequest.Create(txtURL.Text);
// Get the Response from the Request
WebResponse wrResponse = wrRequest.GetResponse();
// Read the Response into a stream and output the stream
Stream objStream = wrResponse.GetResponseStream();
StreamReader objStreamReader = new StreamReader(objStream);
lblHTML.Text += objStreamReader.ReadToEnd();
}
The html it returns includes an image tag with a relative src attribute, like: <img src="2343.jpg">
What I need to do is insert the local path into this src attribute so the image will display in the output... so it should end up like this: <img src="../whateverDirectory/2343.jpg">
Can anyone show me how this can be done? Is there a way to read/replace or something like that?
Thanks!