Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
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
 
Old May 14th, 2010, 10:26 AM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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....
 
Old May 14th, 2010, 10:41 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Where are you opening the window? And where is this C# code placed exactly?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
abhishekkashyap27 (May 14th, 2010)
 
Old May 14th, 2010, 10:53 AM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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....
 
Old May 14th, 2010, 11:14 AM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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
 
Old May 15th, 2010, 01:05 AM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default 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!
 
Old May 15th, 2010, 03:38 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What is the target of the <form /> element you're submittign? Does it still have the query string variables?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 15th, 2010, 05:09 AM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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??
 
Old May 15th, 2010, 10:04 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting values from Popup Window to Parent Window arnabghosh WinForms/Console Application Design 0 October 18th, 2009 12:51 AM
Sending values from Popup to Parent window arnabghosh ASP.NET 3.5 Professionals 1 October 17th, 2009 06:17 AM
Problem in closing the parent window from a popup rakesh.kashnia1 Javascript 4 July 9th, 2007 05:39 AM
Centering Popup window & Blur Parent window jkusmanto Javascript How-To 0 May 25th, 2007 03:19 AM
refresh the parent window when closing the popup ram_siddinen VS.NET 2002/2003 1 January 30th, 2004 04:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.