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 2201
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*******@yaho o.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.Handle r;
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*******@yaho o.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="what ever" 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*******@yaho o.com> wrote: Well, I'm presuming that the name of the webform class is the what was specified as the ClassName="what ever" 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*******@yaho o.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
' then
datasetTarget.Tables(0).Rows.Add(myrow)
dataAdapterTarget.Update(datasetTarget.Tables(0)) '*
|
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 valid.) ERROR which happens on the second page Search.aspx
on the line with (PrevPageValues = (FirstPage)Context.Handler;).
I have also got <%@ Reference Page="_FirstPage.ascx" %> at the top of
the second page.
|
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 5), but fails on IIS 6 running on a Win2003 server.
The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide
some common functionality. The Page_Load handler the failing webpage starts out like this:
...
|
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 DataSet
' Create connection
Dim cn As New OleDbConnection
With cn
.connectionstring =
|
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 length, Int32& dataLength) +195
System.Web.UI.LosFormatter.Deserialize(String input) +60
| |
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 specifiying my code:
The Code used in Visual Studio:
Function GetRank(ByVal ID As Integer, ByVal Comp As String, ByVal Sec As
String, ByVal iDate As Date) As String
'Dim Ret As Integer
|
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 spectacularly. I was so
embarrassed and felt like killing the person that made it fail. However,
when it goes live, IT MUST NOT FAIL.
The system has a backoffice system that takes an excel spreadsheet from the
|
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 a static machinekey in the machine.config and
that did not help. I believe that issue only occurred when there was an
inconsistent viewstate error. The error I am faced with consistently occurs.
Are there any known problems with the ViewState...
|
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 length is 642 bytes ( I have
appended it to the end of this message).
I suspect that the reason may have something to do with an incorrect
declaration of which class to de-serialize to.
In the attached code I substituted @@@@@@@ in the code below with...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |