Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a web form that takes in user input. Then I transfer to a Processing page that tells the user to wait while some stuff is happening, and plays a simple flash animation.

 

Source page (GenerateMR)

protected void cmdGenerateMR_Click(object sender, EventArgs e)
       {
           Server.Transfer("MRProcessing.aspx",true);
       }

 

Then I try to set an object on the destination page so I can read back the values entered on the source page.

Destination Page (MRProcessing)

       private GenerateMR frmSource;
       
       protected void Page_Load(object sender, EventArgs e)
       {            
           if (IsPostBack)
               return;

           //Following throws InvalidCastException
           //Unable to cast object of type 'ASP.fieldservice_generatemr_aspx' to type 'FieldReturns.GenerateMR'.
           //frmSource = (GenerateMR)Context.Handler;

           //also generates above error..
           GenerateMR frmSource = (GenerateMR)PreviousPage;
       }

 

Basically I want to switch to a "Processing files, Please Wait" Page while I am doing stuff on the server. Is this method a good fit, if I can get it working or should I be doing something else.

 

Thanks

MTS

"Beer is proof that God loves us and wants us to be happy."

-Benjamin Franklin

Posted

Fixed...

 

I could not find anyone who had a similar problem, despite hours running various Google searches. I thought I might have a corrupt install or something, so I created a project to test the PreviousPage property and Source.Transfer() function, while stripping away everything else that was irrelevant to the problem. Everything worked as expected.

 

Then I looked closer at the error message and noticed that "ASP.fieldservice_generatemr_aspx" seemed to point to the wrong location. It should have been ASP.fieldservice_SUBFOLDER_generatemr_aspx. Which lead me to suspect I had created the error, which is usually the problem.

 

About a month ago I had moved the source page file into a sub folder in the project after I had created the page. When you create the page the project knows where it is. Then when you move it (drag and drop to new folder) something does not get updated with the new location. When you try to use

<%@ PreviousPageType VirtualPath="SourcePage.aspx" %> 

the program freaks out because it cannot find the source form and cannot cast the page to the appropriate object. I could not find where the update to reflect the move needed to occur (didn't really look:rolleyes:) so to fix I renamed the old page and recreated a new page with the old pages original name. Then copied and pasted the code from the old to the new and presto, everything started working as expected.

 

I should start a blog "How not to code ASPX pages."

MTS

"Beer is proof that God loves us and wants us to be happy."

-Benjamin Franklin

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...