按钮操作以发布网址 [英] button action to post a url

查看:73
本文介绍了按钮操作以发布网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写代码,该代码向带有按钮的人发送电子邮件以跟踪
运输.按钮正在调用的页面具有两个输入值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

推荐答案

您应该在Page Load for Tracking.aspx代码中传递相同的内容以加载数据.也就是说,当您单击按钮并加载页面时,您希望页面加载tID和dID.
要从数据库加载值,只需在Tracking.aspx
上使用如下语法
就我而言,我使用GridView是因为我需要多个值.代码在PageLoad下方.

You should pass the same thing on Page Load for Tracking.aspx code for Loading Data. i.e. you want page to Load tID and dID when you click button and page loads.
To Load Values from database just use syntax like below on Tracking.aspx

In my case I used GridView because I Need more than one value. code is below on PageLoad.

// 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...


这篇关于按钮操作以发布网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆