 |
| ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 14th, 2010, 10:26 AM
|
|
Authorized User
|
|
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Imar
I got what you said but i am not able to understand why it is not working.
Here is the modified code:
C# code calling javascript :
Code:
ClientScript.RegisterStartupScript(typeof(Page), "myscript", string.Format("<script>CloseWindow('{0}');</script>", "AWD_Nomination_TOM.aspx?Mode=" + "AWD" + "&SessionId=" + SessionId +
"&AsscLst=" + Session["ASSCLIST"]));
Now CloseWindow() is my javascript function:
Code:
function CloseWindow(url)
{
window.opener.document.forms[0].submit();
self.close();
}
But this is causing postback in the popup page rather than in the parent page. I tried putting the form id of the parent page in here:
window.opener.document.forms["frmAcc"].submit();
but this also do postback in the popup page....
|
|

May 14th, 2010, 10:41 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Where are you opening the window? And where is this C# code placed exactly?
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

May 14th, 2010, 10:53 AM
|
|
Authorized User
|
|
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
That problem was a just a type error from my side(sorry for that) but now the code works but dont cause postback in the parent page, the popup window just closes but my debug point doesnt get fired in the parent page. Here is the method in popup page which calls javascript :
Code:
void btnSubmit_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("EMPNO"));
dt.Columns.Add(new DataColumn("NAME"));
dt.Columns.Add(new DataColumn("DESIGNATION"));
dt.Columns.Add(new DataColumn("REMARKS"));
DataRow dr;
DataSet dsAWD = new DataSet();
dt.TableName = "ASSOCIATELIST";
dsAWD.Tables.Add(dt);
foreach (ListItem item in lstAssList.Items)
{
if (item.Selected.Equals(true))
{
dr = dt.NewRow();
string[] chk1 = item.Value.Trim().Split('-');
string[] chk = item.Text.Trim().Split('-');
dr["EMPNO"] = chk1[0].ToString().Trim();
dr["NAME"] = chk[0].ToString().Trim();
dr["DESIGNATION"] = chk1[1].ToString().Trim();
dr["REMARKS"] = System.DBNull.Value;
dt.Rows.Add(dr);
}
}
Session["ASSCLIST"] = dt;
ClientScript.RegisterStartupScript(typeof(Page), "myscript", string.Format("<script>CloseWindow('{0}');</script>", "AWD_Nomination_TOM_Acceptance.aspx?Mode=" + "AWD" + "&SessionId=" + SessionId +
"&AssLst=" + Session["ASSCLIST"]));
}
the javascript code:
Code:
function CloseWindow(url)
{
window.opener.document.forms[0].submit();
self.close();
}
now the javascript does gets executed but it doesn'get redirected to my parent page, my debug point in the page load of parent doesn't get fired. I have checked the url spelling, it's correct....
|
|

May 14th, 2010, 11:14 AM
|
|
Authorized User
|
|
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
I restarted visual studio on my laptop and the debug point came alive in the parent page with the control retaining the values, cant tell you the happiness on my face after seeing this, i dont know what explanation to give or you will give regarding this.... :)
Well, Imar , you are a life saver man, thanks a lot for the patience and helping me out, i owe you one :D; thanks again for the valuable support, you rock buddy! have a nice day ahead..
Best Regards,
Abhishek
INDIA
|
|

May 15th, 2010, 01:05 AM
|
|
Authorized User
|
|
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Query string value is null???
Hi Imar
Code:
window.opener.document.forms[0].submit();
Does this code allows query string to be passed??? I am getting my query string value always null in the parent page!
|
|

May 15th, 2010, 03:38 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
What is the target of the <form /> element you're submittign? Does it still have the query string variables?
Imar
|
|

May 15th, 2010, 05:09 AM
|
|
Authorized User
|
|
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Imar
From C# code, the query string is being sent, again the same code:
Code:
ClientScript.RegisterStartupScript(typeof(Page), "myscript", string.Format("<script>CloseWindow('{0}');</script>", "AWD_Nomination_TOM.aspx?Mode=" + "AWD" + "&SessionId=" + SessionId +
"&AsscLst=" + Session["ASSCLIST"]));
But this doesn't work. What i did is that i targeted the hidden control of the parent page and assign value to it through javascript. Here is the modified javascript :
Code:
function CloseWindow(url)
{
window.opener.document.getElementById("hdnAssc").value = document.getElementById("hdnPass").value;
window.opener.document.forms[0].submit();
self.close();
}
hdnPass is the hidden control in my popup page.Here i build up the query string and assign it to hdnPass cntrl and then in the javascript i assign it back to the hdnAssc(which is actually hidden control in the parent page), it does work. But the question is that if i need to pass 5 to 6 query string then do i have to declare 5 to 6 controls in the parent page??
|
|

May 15th, 2010, 10:04 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Why not write out the entire query string as a string and use a single hidden control?
Since I don't really know what you're doing, I can't really understand if this is really has to be so complex. I would simply repost the original page, and optionally pass some extra data in one or more hidden fields.
Cheers,
Imar
|
|
 |