0

I've this problem. Two pages: a parent and a child called in popup window by javascript. The child page is a search page. In this user can select one of the results and resend it to the parent page by querystring and javascript.

this is the script I use to do this in codebehind of search.aspx:

protected void Button4_Click(object sender, EventArgs e)
    {
        string url2 = "";

        if (GridView1.Rows.Count == 0)
        {
            string myStringVariable = string.Empty;
            myStringVariable = "Nessuna ricerca effettuata!";
            ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
        }
        else 
        {
            bool chk = false;

            foreach (GridViewRow row in GridView1.Rows)
            {
                RadioButton rad = (RadioButton)row.FindControl("RadioButton1");
                Label lb1 = (Label)row.FindControl("Label1");

                if (rad.Checked)
                {
                    chk = true;
                    url2 = "classmer.aspx?cod=" + lb1.Text;
                    break;
                }
            }
            if (chk)
            {
                StringBuilder st = new StringBuilder();
                st.Append("<script language='javascript'>");
                st.Append("window.opener.location = '" + url2 + "';");
                st.Append("self.close();");
                st.Append("</script>");
                ClientScript.RegisterStartupScript(typeof(Page), "", st.ToString());
            }
            else if (!chk)
            {
                string myStringVariable = string.Empty;
                myStringVariable = "Nessun mercato selezionato!";
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
            }
        }       

now let's pass to the 404 error. the parent page has this url "http://localhost/App/ClassMer/classmer.aspx" the child page has this url "http://localhost/App/ClassMer/search.aspx"

by clicking the confirm button on search page, it resend to this url "http://localhost/ClassMer/classmer.aspx" bypassing the "App" folder (that is a virtal path created in IIS7 when deploying the application.)

how can I resolve this?

I tried some solution like adding Request.ApplicationPath or directly specifing by string the path to the url I pass to javascript but none happened.

Help, please!!

Thanks

Kyashan
  • 1
  • 2
  • Do you mean that when the confirm button is clicked, it sends them to the classmer.aspx, not the search.aspx? – Kasaku Sep 20 '11 at 13:54
  • yes. the button is on the search.aspx. by clicking it js will resend to classmer.aspx and add the querystring. but the problem is that it can locate properly the parent page (see latest url) – Kyashan Sep 20 '11 at 14:10
  • Ok, you may want to edit your question then to correct that URL to make it more understandable. – Kasaku Sep 20 '11 at 14:37
  • Thx, you were right. Now it's ok ;) – Kyashan Sep 21 '11 at 09:48

1 Answers1

0

Request.ApplicationPath should be fine I'd have thought. Try the following:

url2 = HttpRuntime.AppDomainAppVirtualPath + "/classmer.aspx?cod=" + lb1.Text;
Kasaku
  • 2,192
  • 16
  • 26
  • Thanks Pirate, but it doesn't work :\ same error and same requested path – Kyashan Sep 20 '11 at 14:04
  • Can you updated your question and include the Javascript that is being written out to the page in the popup? Assuming this is where the problem lies. – Kasaku Sep 20 '11 at 14:38