I am attempting to pass data between two asp.net web forms pages. I
have found the method to do this on the msdn site here: http://msdn.microsoft.com/library/de...tweenPages.asp
After attempting to do this myself, I kept getting an Invalid Cast
Exception error, so I finally resorted to simply copying and pasting
the MS code in this article into two pages for the purpose of testing.
Surprisingly, I found myself with the exact same invalid cast error. No
idea what I'm missing here. 9 2172
Buzz:
Do you know what line of code was throwing an InvalidCast error?
--
Scott http://www.OdeToCode.com/blogs/scott/
On 18 Mar 2005 08:20:35 -0800, "buzz" <rb*******@yahoo.com> wrote: I am attempting to pass data between two asp.net web forms pages. I have found the method to do this on the msdn site here:
http://msdn.microsoft.com/library/de...tweenPages.asp
After attempting to do this myself, I kept getting an Invalid Cast Exception error, so I finally resorted to simply copying and pasting the MS code in this article into two pages for the purpose of testing. Surprisingly, I found myself with the exact same invalid cast error. No idea what I'm missing here.
Line 16, where i am casting the Context.Handler to the classname
specified in the page directive of the sending page.
HI Buzz:
If it's a line like this:
FirstPageClass fp = (FirstPageClass)Context.Handler;
then Handler isn't a FirstPageClass object. What was the name of the
webform class that did the Server.Transfer?
--
Scott http://www.OdeToCode.com/blogs/scott/
On 18 Mar 2005 08:33:20 -0800, "buzz" <rb*******@yahoo.com> wrote: Line 16, where i am casting the Context.Handler to the classname specified in the page directive of the sending page.
Well, I'm presuming that the name of the webform class is the what was
specified as the ClassName="whatever" portion of the @ Page directive
on the sending page. At least, that is the way it is explained in the
article. Like I said in my original post, I copied the code from the
microsoft article exactly, so the ClassName in the page directive of
the sending page is "FirstPageClass"
My understanding was that the Context.Handler contained all the
pertinent info when the Server.Transfer took place, and that you needed
to create an instance of the sending page class, then set it equal to
the Context.Handler. Because the Context.Handler is generic, it has to
be cast as the sending page class in order to do this.
But that's where I have a problem. I'm just lost, given that the MS
code does the exact same thing. I haven't made any code changes to the
code they posted in the article.
Hi buzz:
On 18 Mar 2005 10:38:19 -0800, "buzz" <rb*******@yahoo.com> wrote: Well, I'm presuming that the name of the webform class is the what was specified as the ClassName="whatever" portion of the @ Page directive on the sending page. At least, that is the way it is explained in the article. Like I said in my original post, I copied the code from the microsoft article exactly, so the ClassName in the page directive of the sending page is "FirstPageClass"
Yes, that should be working for you then. I'm not sure what would be
going wrong.
My understanding was that the Context.Handler contained all the pertinent info when the Server.Transfer took place, and that you needed to create an instance of the sending page class, then set it equal to the Context.Handler. Because the Context.Handler is generic, it has to be cast as the sending page class in order to do this.
that's all correct, except your code doesn't need to create an
instance of the sending page class, it just declares a variable of the
type and gets the instance from Context.Handler.
But that's where I have a problem. I'm just lost, given that the MS code does the exact same thing. I haven't made any code changes to the code they posted in the article.
Are you using VisualStudio? In the debugger you can stop execution on
that line of code and inspect Context.Handler to get information about
it.
--
Scott http://www.OdeToCode.com/blogs/scott/
No, i'm not using studio. Just using DreamweaverMX using code view to
do my stuff. Actually, I've narrowed down the problem to something on
my laptop. I loaded the files up to a server and it worked ok. Not sure
what is different, or if there is maybe something I need to install on
my laptop??? Laptop is an XP Pro workstation... My web stuff has always
worked previously on my laptop...
Write out to the Trace or Response.write the Context.Handler type. Usually
ToString() will give you this.
"buzz" wrote: No, i'm not using studio. Just using DreamweaverMX using code view to do my stuff. Actually, I've narrowed down the problem to something on my laptop. I loaded the files up to a server and it worked ok. Not sure what is different, or if there is maybe something I need to install on my laptop??? Laptop is an XP Pro workstation... My web stuff has always worked previously on my laptop...
Well, i think i have it figured out. The problem was not with my code,
but rather with how i was accessing the pages. I was using the preview
function of Dreamweaver, which renders your page out to a temp file and
then displays it in a browser. That was my problem. The page reference
in the second page was not working because the first page was a temp
file. I accessed the pages normally using a browser, outside of DW, and
it worked perfectly. Thanks for all the suggestions.
Ah, I'm glad it's working now. It sounded like you had everything
lined up right.
--
Scott http://www.OdeToCode.com/blogs/scott/
On 18 Mar 2005 14:16:09 -0800, "buzz" <rb*******@yahoo.com> wrote: Well, i think i have it figured out. The problem was not with my code, but rather with how i was accessing the pages. I was using the preview function of Dreamweaver, which renders your page out to a temp file and then displays it in a browser. That was my problem. The page reference in the second page was not working because the first page was a temp file. I accessed the pages normally using a browser, outside of DW, and it worked perfectly. Thanks for all the suggestions. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: |
last post by:
When I execute the following (with an OleDBDataAdapter),
wanting to add a row to a visual foxpro table:
myrow= datasetTarget.Tables(0).NewRow
'fill all columns here like..
row(i)= myvalue
'...
|
by: Andrew |
last post by:
Can someone out there help. I am using Server.
Transfer from a user control to a webform and tried to follow many
examples exactly as specified but cannot get around the (Specified
cast is not...
|
by: Nick Flandry |
last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my
development environment (Win2K server running IIS 5) and a test environment (also Win2K server
running IIS...
|
by: John Howard |
last post by:
Making the following call to a local MSAccess database works fine:
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim intRows As Integer
Dim strSQL As String
Dim ds As New...
|
by: vinay |
last post by:
What is this error??
Exception Details: System.Web.HttpException: Unable to validate data.
System.Web.Configuration.MachineKey.GetDecodedData(Byte buf, Byte
modifier, Int32 start, Int32...
|
by: Hifni Shahzard |
last post by:
Hi,
I got a stored procedure, where it returns a value. But if I execute it. It
gives an error as "Invalid cast from System.Int32 to System.Byte.". To make
clear how do I execute this, below I'm...
|
by: David |
last post by:
Hi,
I have built a web application that will be a very high profile application.
We had tested it, demonstrated it and shown that it all works.
On a dress rehearsal run through, it failed...
|
by: Jamie |
last post by:
I am receiving an Invalid ViewState error after posting back to the same page
twice. Consistently the error occurs after the second postback and not after
the first.
I have looked into creating...
|
by: MR |
last post by:
I get the following Exception "The data at the root level is invalid. Line
1, position 642" whenever I try to deserialize an incoming SOAP message. The
incoming message is formed well and its...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |