473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

CSharp to VB.Net (aspx page)

In C# I can do:
((Page)this.Parent).Title = "Title"

Why doesn't this work in VB:
DirectCast(me.Parent, Page).Title = "Title"
The Title var doesn't show up in VB.

Thanks.
Chris
Nov 19 '05 #1
2 1449
Use CType(me.Parent, Page).Title = "Title"

The diffeence is the CType will convert to any type that can be converted to
the type. DirectCast only casts the type if the type is exactly the same.
Since your Page class is not System.Web.UI.Page, but a derived class with a
different name, DirectCast will fail unless you cast it to the exact type of
your page class.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.

"Chris" <no@spam.com> wrote in message
news:eR**************@TK2MSFTNGP11.phx.gbl...
In C# I can do:
((Page)this.Parent).Title = "Title"

Why doesn't this work in VB:
DirectCast(me.Parent, Page).Title = "Title"
The Title var doesn't show up in VB.

Thanks.
Chris

Nov 19 '05 #2
Kevin Spencer wrote:
Use CType(me.Parent, Page).Title = "Title"

The diffeence is the CType will convert to any type that can be converted to
the type. DirectCast only casts the type if the type is exactly the same.
Since your Page class is not System.Web.UI.Page, but a derived class with a
different name, DirectCast will fail unless you cast it to the exact type of
your page class.

I'm sorry but I have to disagree with you.

This code converts the object to a Page object
((Page)this.Parent).Title

So does this code.
DirectCast(me.Parent, Page).Title

The problem isn't the casting to a page object, the code isn't failing
at design time cause of a miscast. The problem is that it says the page
object doesn't have a title property on it.

My real question is:
Page.Title exists in C# but not in VB? What am I not doing in VB to get
the page.title property.

Chris
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mr. x | last post by:
Hello, where can I find csharp tutorial/help/samples. *.chm file is preffered. Thanks :)
0
by: Michael Meckelein | last post by:
Hi all, some strange things are going on. I have a c# project to automate word written under VS.NET with Office XP PIAs. It is a web application project using ASP.NET, programming language is...
3
by: Chumley Walrus | last post by:
I'm trying to either have a user hit a Refresh button to refresh a mobile aspx (c-sharp behind code) page , or using an automatic refresh every 3 minutes on the page. <META HTTP-EQUIV="Refresh"...
2
by: Keith Clark | last post by:
Yes, I know at the webpage http://msdn.microsoft.com/vstudio/express/visualcsharp/download/default.aspx I can download Visual CSharp Express software. But this is only a 3MB setup wizard...
10
by: CSDunn | last post by:
Hello, I'm having a problem with ASP.NET using IIS 5.1 on a Windows XP Pro machine. ASP.NET will not process the following code: ******************************* <html> <head> </head> <body>...
0
by: sridev | last post by:
i am new to ASP.NET with CSharp. I am having an application, Which has a web form as Home.aspx. In that page iloaded a user control web form (Insertclient.ascx) in the page load.Now i have a next...
2
by: Joshua Tan | last post by:
hey there, I really need some help with this. I have a web application running on Windows 2000 Server , IIS5.0 , .Net Framework 1.1 I have a file.aspx, file.aspx.cs and file.aspx.resx I...
10
by: Brian Parker | last post by:
I inherited a C++ DLL that I need to remotely call multiple times asynchronously. What I have developed is: CSharp web application that makes asynchronous calls to a CSharp Web Service. The...
3
by: =?Utf-8?B?R3JlZw==?= | last post by:
I''ve been working with a CSharp web-site (and am new to it). I have a javascript function that accepts variables from my CSharp code. It all works fine, with the exception of one variable type. I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.