问题描述
我正在编写代码,该代码向带有按钮的人发送电子邮件以跟踪
运输.按钮正在调用的页面具有两个输入值tID和dID
像
这样的网址www.shippingcompany.com/tracking.aspx?tID=234003&dID=tx2333
当我将以上链接与按钮单击操作一起使用时,它不起作用,将显示正常页面以手动输入值.有什么想法去做吗?
谢谢
Hi I am writing code which sends email to a person with button in it to track
shipping. The page the button is calling takes two input values tID and dID
url like,
www.shippingcompany.com/tracking.aspx?tID=234003&dID=tx2333
When i use this above link with button click action it doesnt work, displays the normal page to enter values manually. Any ideas how to go about doing it?
Thanks
推荐答案
// Code for Tracking.aspx
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindDList();
}
}
void BindDList()
{
string PCode = Request["PCode"].ToString();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyShop"].ConnectionString);
SqlDataAdapter adp = new SqlDataAdapter("Select * from Products where ProductID in (" + PCode + ")",con);
DataSet ds = new DataSet();
adp.Fill(ds);
GView1.DataSource = ds.Tables[0];
GView1.DataBind();
}
现在,在我的情况下,要从其中发送tID和dID的Button Click代码,这里是PCode.
如果您在页面中使用网格视图",则代码如下所示:
Now code for Button Click from where you want to send tID and dID in my case PCode is here.
If you are using Grid View in page then code is like this:
string PCode = "";
Label lblPCode = (Label)DList1.Items[i].FindControl("PCode");
PCode = lblPCode.Text;
Response.Redirect("Tracking.aspx?PCode=" + PCode);
而且,如果您只是从表或Div发送ID,请像这样更改代码,
And if you are simply sending IDs from table or Div change your code like this,
string tID = txtTID.Text;
string dID = txtDID.text;
Response.Redirect("Tracking.aspx?tID="+tID+"&dID="+dID);
祝你好运...
Good Luck...
这篇关于按钮操作以发布网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!