Using QueryString
-
I am trying to pass a value from a pop up window back to the parent page. The query string is successful, but it wont go back to the previous page, but instead the pop-up window will redirect to the previous page with the values. What I want to do is close the pop-up window, and go back to the previous page with the values. Here are the code that I currently have: //this is action performed when the button to submit the values are clicked
protected void btnSelect_Click(object sender, EventArgs e)
{
GridViewRow row = grdAll.Rows[SelectedProductIndex];name = row.Cells\[2\].Text.ToString(); Industry = row.Cells\[3\].Text.ToString(); SubInd = row.Cells\[4\].Text.ToString() ; geo = row.Cells\[5\].Text.ToString(); location = row.Cells\[6\].Text.ToString(); Page.Response.Redirect("frmMain.aspx?name=" + name + "&industry=" + Industry + "&subInd=" + SubInd + "&geo=" + geo + "&location=" + location); }
//this is the page_load of the parent window
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Page.Request.QueryString["name"] != null)
{
txtMPSname.Text = Page.Request.QueryString["name"].ToString();
txtLoc.Text = Page.Request.QueryString["location"].ToString();
DlstGeo.Text = Page.Request.QueryString["geo"].ToString();
DlstInd.Text = Page.Request.QueryString["industry"].ToString();
DlstSubInd.Text = Page.Request.QueryString["subInd"].ToString();
}
}
} -
I am trying to pass a value from a pop up window back to the parent page. The query string is successful, but it wont go back to the previous page, but instead the pop-up window will redirect to the previous page with the values. What I want to do is close the pop-up window, and go back to the previous page with the values. Here are the code that I currently have: //this is action performed when the button to submit the values are clicked
protected void btnSelect_Click(object sender, EventArgs e)
{
GridViewRow row = grdAll.Rows[SelectedProductIndex];name = row.Cells\[2\].Text.ToString(); Industry = row.Cells\[3\].Text.ToString(); SubInd = row.Cells\[4\].Text.ToString() ; geo = row.Cells\[5\].Text.ToString(); location = row.Cells\[6\].Text.ToString(); Page.Response.Redirect("frmMain.aspx?name=" + name + "&industry=" + Industry + "&subInd=" + SubInd + "&geo=" + geo + "&location=" + location); }
//this is the page_load of the parent window
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Page.Request.QueryString["name"] != null)
{
txtMPSname.Text = Page.Request.QueryString["name"].ToString();
txtLoc.Text = Page.Request.QueryString["location"].ToString();
DlstGeo.Text = Page.Request.QueryString["geo"].ToString();
DlstInd.Text = Page.Request.QueryString["industry"].ToString();
DlstSubInd.Text = Page.Request.QueryString["subInd"].ToString();
}
}
} -
I am trying to pass a value from a pop up window back to the parent page. The query string is successful, but it wont go back to the previous page, but instead the pop-up window will redirect to the previous page with the values. What I want to do is close the pop-up window, and go back to the previous page with the values. Here are the code that I currently have: //this is action performed when the button to submit the values are clicked
protected void btnSelect_Click(object sender, EventArgs e)
{
GridViewRow row = grdAll.Rows[SelectedProductIndex];name = row.Cells\[2\].Text.ToString(); Industry = row.Cells\[3\].Text.ToString(); SubInd = row.Cells\[4\].Text.ToString() ; geo = row.Cells\[5\].Text.ToString(); location = row.Cells\[6\].Text.ToString(); Page.Response.Redirect("frmMain.aspx?name=" + name + "&industry=" + Industry + "&subInd=" + SubInd + "&geo=" + geo + "&location=" + location); }
//this is the page_load of the parent window
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Page.Request.QueryString["name"] != null)
{
txtMPSname.Text = Page.Request.QueryString["name"].ToString();
txtLoc.Text = Page.Request.QueryString["location"].ToString();
DlstGeo.Text = Page.Request.QueryString["geo"].ToString();
DlstInd.Text = Page.Request.QueryString["industry"].ToString();
DlstSubInd.Text = Page.Request.QueryString["subInd"].ToString();
}
}
}Hi, Instead of "Response.Redirect()" use the javascript function like this.
function closeFrm(val1,val2,val3,val4,val5)
{
self.close();
window.opener.location.href = "frmMaain.aspx?name=val1&location=val2&geo=val3&industry=val4&subInd=val5";
}and call this function through code as below.
ScriptManager.RegisterClientSciptBlock(this,this.GetType(),"Myscript","closeFrm('"+ name +"','"+ location +"','"+ geo +"','"+ Industry +"','"+ SubInd +"'");
Hope it works.
with regards Karthik Harve
-
Hi, Instead of "Response.Redirect()" use the javascript function like this.
function closeFrm(val1,val2,val3,val4,val5)
{
self.close();
window.opener.location.href = "frmMaain.aspx?name=val1&location=val2&geo=val3&industry=val4&subInd=val5";
}and call this function through code as below.
ScriptManager.RegisterClientSciptBlock(this,this.GetType(),"Myscript","closeFrm('"+ name +"','"+ location +"','"+ geo +"','"+ Industry +"','"+ SubInd +"'");
Hope it works.
with regards Karthik Harve
I'm getting an error :
Error 1 'System.Web.UI.ScriptManager' does not contain a definition for 'RegisterClientSciptBlock'
on this line
ScriptManager.RegisterClientSciptBlock
thanks,
-
I'm getting an error :
Error 1 'System.Web.UI.ScriptManager' does not contain a definition for 'RegisterClientSciptBlock'
on this line
ScriptManager.RegisterClientSciptBlock
thanks,
That's a typo. Obviously he meant:
ScriptManager.RegisterClientScriptBlock
/ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com