开发者

Popup asp.net page, javascript and path error 404

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.RegisterStartupScr开发者_如何学编程ipt(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


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

url2 = HttpRuntime.AppDomainAppVirtualPath + "/classmer.aspx?cod=" + lb1.Text;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜