如何将值从页面传递到弹出窗口,然后通过查询字符串弹出到下一页 [英] how to pass values from page to popup and then popup to next page through querystring

查看:64
本文介绍了如何将值从页面传递到弹出窗口,然后通过查询字符串弹出到下一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一页的值传递给第二页,但在第一页上,我想在linkbutton上显示show popup for login。我正在使用listview



//第一页上的mycode linkbuttn在列表视图中





  protected   void  LstvwProSubCat_ItemCommand(对象发​​件人,ListViewCommandEventArgs e)
{

if (ProfileID == 0
{
MpeLogin.Show();
// MessageBox.Show(查看首先需要登录的产品标题);

}
else
{
if (e.CommandName == ProSubCategary
{
);

string [] args = e.CommandArgument.ToString()。Split( new char [] {' ,'});
int pgid = Convert.ToInt32(args [ 0 ]);
int pcid = Convert.ToInt32(args [ 1 ]);
int psdid = Convert.ToInt32(args [ 2 ]);
Server.Transfer( product_title.aspx?pgid =' + pgid + '& pcid =' + pcid + '& psdid =' + psdid + ');
}

}
}





//弹出窗口代码



 受保护  void  BtnATLogin_Command( object  sender,CommandEventArgs e)
{
if (e。 CommandName == 登录
{
string [] args = e.CommandArgument.ToString()。Split( new char [] {' ,'});
int pgid = Convert.ToInt32(args [ 0 ]);
int pcid = Convert.ToInt32(args [ 1 ]);
int psdid = Convert.ToInt32(args [ 2 ]);
Server.Transfer( product_title.aspx?pgid =' + pgid + '& pcid =' + pcid + '& psdid =' + psdid + ');
}
}



//下一页

<前lang =cs> string val1 = Request.QueryString [ 0 ];
string val2 = Request.QueryString [ 1 ];
string val3 = Request.QueryString [ 2 ];

解决方案

潜在的地方看起来像:

  int  pgid = Convert.ToInt32(args [ 0 ]); 
int pcid = Convert.ToInt32(args [ 1 ]);
int psdid = Convert.ToInt32(args [ 2 ]);



您正在将字符串直接转换为Int32。确保所有这些实际上都可以转换为整数。





其他一些观察结果:

1.我希望ProfileID是你在比较中使用的整数在if语句中

2.不确定为什么你将字符串数组转换为整数然后再转换为字符串连接。

而不是下面:

  string  [] args = e.CommandArgument.ToString()。Split( new   char  [] {' ,'}); 
int pgid = Convert.ToInt32(args [ 0 ]);
int pcid = Convert.ToInt32(args [ 1 ]);
int psdid = Convert.ToInt32(args [ 2 ]);
Server.Transfer( product_title.aspx?pgid =' + pgid + '& pcid =' + pcid + '& psdid =' + psdid + ');



它本可以完成的:

  string  [] args = e.CommandArgument.ToString()。Split( new   char  [] {' ,'}); 
Server.Transfer( product_title.aspx?pgid =' + args [ 0 ] + '& pcid =' + args [ 1 ] + '& psdid =' + args [ 2 ] + );


I want to pass values of one page to 2nd but on 1st page i want show popup for login on linkbutton. i am using listview

//mycode on 1st page linkbuttn in listview


protected void LstvwProSubCat_ItemCommand(object sender, ListViewCommandEventArgs e)
    {

        if (ProfileID == 0)
        {
            MpeLogin.Show();
            //MessageBox.Show("To View Product Title You Need To Login First");

        }
        else
        {
            if (e.CommandName == "ProSubCategary")
            {
              );

                string[] args = e.CommandArgument.ToString().Split(new char[] { ',' });
                int pgid = Convert.ToInt32(args[0]);
                int pcid = Convert.ToInt32(args[1]);
                int psdid = Convert.ToInt32(args[2]);
                Server.Transfer("product_title.aspx?pgid='" + pgid + "' & pcid='" + pcid + "'&psdid='" + psdid + "'");
            }

        }
    }



//code for popup

protected void BtnATLogin_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "Login")
        {
            string[] args = e.CommandArgument.ToString().Split(new char[] { ',' });
            int pgid = Convert.ToInt32(args[0]);
            int pcid = Convert.ToInt32(args[1]);
            int psdid = Convert.ToInt32(args[2]);
            Server.Transfer("product_title.aspx?pgid='" + pgid + "' & pcid='" + pcid + "'&psdid='" + psdid + "'");
        }
    }


//next page

string val1 = Request.QueryString[0];
        string val2 = Request.QueryString[1];
        string val3 = Request.QueryString[2];

解决方案

Potential place looks like:

int pgid = Convert.ToInt32(args[0]);
int pcid = Convert.ToInt32(args[1]);
int psdid = Convert.ToInt32(args[2]);


You are directly converting the strings into Int32. Make sure all of them are actually convertible to integer.


Couple of other observations:
1. I hope ProfileID is an integer as you used in comparison in if statement
2. Not sure why you converted the string array into integers and then back to string concatenation.
Instead of below:

string[] args = e.CommandArgument.ToString().Split(new char[] { ',' });
int pgid = Convert.ToInt32(args[0]);
int pcid = Convert.ToInt32(args[1]);
int psdid = Convert.ToInt32(args[2]);
Server.Transfer("product_title.aspx?pgid='" + pgid + "' & pcid='" + pcid + "'&psdid='" + psdid + "'");


it could have been done as:

string[] args = e.CommandArgument.ToString().Split(new char[] { ',' });
Server.Transfer("product_title.aspx?pgid='" + args[0] + "' & pcid='" + args[1] + "'&psdid='" + args[2] + "'");


这篇关于如何将值从页面传递到弹出窗口,然后通过查询字符串弹出到下一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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