0
我对从其他网站检索数据有疑问。检索数据并正确显示
我Default.aspx的是这样的:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox runat="server" ID="txtInput"></asp:TextBox><br /><br />
<asp:Button runat="server" ID="btnSubmit" Text="Submit"
onclick="btnSubmit_Click" /><br /><br />
<asp:Label runat="server" ID="lblResult1" Text=""></asp:Label>
</div>
</form>
</body>
</html>
像这样它后面的代码:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
System.Net.WebClient wc = new System.Net.WebClient();
lblResult1.Text =
wc.DownloadString(string.Format("http://foo.com/servlet/AccessModule?id={0}&doc_type1=xyz&response=K", txtInput.Text));
}
}
它只是从上面的URL读取数据,并在我的网页上显示。
例如,如果我在文本框中输入12345678。
的结果是这样的:
现在我想要做的是使结果可点击的是最后一部分的内容。 (http://foo.com/report/svc/id=000001DF-D80AB26F-C7D2-4FC3-ADD6-361E6630D572)
任何想法?
它给错误。 – sensahin
可能是因为你下载了一个字符串。请在标签内下载它,然后lblResult1.Text = String.Format(“”); –
对不起,如果这个问题太傻了。现在我收到此消息:在当前上下文中不存在名称'labelText' – sensahin