0

this.Page.PreviousPage と thisPage.PreviousPage のようなものを使用するたびに、値を取得する代わりにページを実行するようです。

コードで使用するたびに、Masterage.aspx.csファイルに設定したエラーページにリダイレクトされ、ユーザーがアクセスできるページにリダイレクトされるためです。ブレークポイントを実行すると、プログラムはこれらの行のエラーページにリダイレクトされるため、これらの行でのみ発生します。

        if (this.Page.PreviousPage != null) //This checks if the previous page is not empty
        {
            GridView gridViewToExport = new GridView();
            string gridViewName = Request.QueryString["gridviewname"];

            //Check if the masterpage contentplaceholder exists
            if (this.Page.PreviousPage.Master.FindControl("CPH1") != null)
            {
                //If Exists then do this steps
                Control ContentPlaceHolder1 = this.Page.PreviousPage.Master.FindControl("CPH1");
                gridViewToExport = (GridView)ContentPlaceHolder1.FindControl(gridViewName);
            }
            else
            {
                //If is not existent, then continue with this.
                gridViewToExport = (GridView)this.Page.PreviousPage.FindControl(gridViewName);
            }

            frmExportarDatos.EnableViewState = false;
            frmExportarDatos.Controls.Add(gridViewToExport);
        }

これから取得するエラーは、「this.Page.PreviousPage」が「System.Threading.ThreadAbortException」型の例外をスローした System.Web.UI.Page {System.Threading.ThreadAbortException} です。

4

1 に答える 1