postbackurl在Imagebutton中不起作用 [英] postbackurl not working in Imagebutton

查看:97
本文介绍了postbackurl在Imagebutton中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

图片按钮postbackurl无法正常工作它不指向目标页面和图像按钮它不在任何控件内,如gridview或Datalist,它是单独的,这是我的代码



Image button postbackurl is not working its not directing to the destination page and imagebutton its not inside any control like gridview or Datalist its seperate and this is my code

<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/icon-continue-shopping-4-150x49.jpg" PostBackUrl='<%#"Order_Details.aspx?pid="+Eval("ProductID") %>'/>



和Order_Details.aspx中的代码




And code in the Order_Details.aspx

 protected void Page_Load(object sender, EventArgs e)
    {

        BindGridData();
        if (!IsPostBack)
        {
        }
    }
    protected void Button1_Click1(object sender, EventArgs e)
    {

    }
    private void BindGridData()
    {
        try
        {
            con.Open();
            int pitemid = Convert.ToInt32(Request.QueryString["pid"].ToString());
            {
                string sql = "select * from rsa_ProductItemTable where ProductID=" + pitemid;
                SqlCommand cmd = new SqlCommand(sql, con);
                SqlDataAdapter da = new SqlDataAdapter(sql, con);
                DataSet ds = new DataSet();
                da.Fill(ds);
                GridView1.DataSource = ds;
                GridView1.DataBind();
            }
        }

        catch (Exception ex)
        {
        }
        finally
        {
            con.Close();
        }
    }
}



请帮我解决这个问题。在此先感谢!!


Please help me to solve this. Thanks in Advance!!

推荐答案

虽然你已经清楚地提到图像按钮不在gridview或datalist之类的任何控件内,但我仍然会问,你确定吗?

Although you have clearly mentioned that the image button is not inside any control like gridview or datalist, still I'll ask, are you sure?
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/icon-continue-shopping-4-150x49.jpg" PostBackUrl="<%#"Order_Details.aspx?pid="+Eval("ProductID") %>" />



什么 Eval(ProductID)应评估为?



只是为了测试你可以尝试用


What Eval("ProductID") should evaluate to?

Just for a test you can try replacing the above snippet with

<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/icon-continue-shopping-4-150x49.jpg" PostBackUrl="Order_Details.aspx?pid=1" />



它应该重定向到 Order_Details.aspx ,pid = 1,你写的逻辑将被执行。



我相信,你想让这个图像按钮重定向到其他地方。

如果你想做的话你也可以使用 OnClick 事件它的另一种方式。



如果你的问题没有解决,请告诉我:))


It should redirect to Order_Details.aspx with pid=1 and the logic you have written will be executed.

I am sure, you want this image button to redirect somewhere else.
You can also use OnClick event if want to do it other way.

In case, your problem is not resolved, please let me know :)


这篇关于postbackurl在Imagebutton中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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