0

私はこの問題を抱えています。2 つのページ: javascript によってポップアップ ウィンドウで呼び出される親と子。子ページは検索ページです。このユーザーでは、結果の 1 つを選択し、クエリ文字列と JavaScript によって親ページに再送信できます。

これは、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);
            }
        }       

では、404 エラーに移りましょう。親ページの URL は「http://localhost/App/ClassMer/classmer.aspx」、子ページの URL は「http://localhost/App/ClassMer/search.aspx」です。

検索ページの確認ボタンをクリックすると、「App」フォルダ(アプリケーションのデプロイ時に IIS7 で作成される仮想パス)をバイパスして、この URL「http://localhost/ClassMer/classmer.aspx」に再送信されます。

どうすればこれを解決できますか?

Request.ApplicationPath を追加するか、javascript に渡す URL へのパスを文字列で直接指定するなどの解決策を試しましたが、何も起こりませんでした。

助けてください!!

ありがとう

4

1 に答える 1

0

Request.ApplicationPath大丈夫だと思っていたはずです。次のことを試してください。

url2 = HttpRuntime.AppDomainAppVirtualPath + "/classmer.aspx?cod=" + lb1.Text;
于 2011-09-20T13:56:51.160 に答える