473,396 Members | 1,998 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,396 software developers and data experts.

Conversion of Usercontrol from VB.Net to C#

Hi everyone,

My client is requiring me to convert an existing web app from VB.Net to
C# to become more inline with their existing codebase.

I am running into a problem when converting a usercontrol, basically the
usercontrol has a property which is set by the hosting page, to indicate
if a user is logged in or not. This controls the navigation menu which
the user see's.

In the VB version its just a matter of:
Private _UserIsLoggedIn As Boolean

Public Property UserIsLoggedIn() As Boolean
Get
Return _UserIsLoggedIn
End Get
Set(ByVal value As Boolean)
_UserIsLoggedIn = value
End Set
End Property

So I convert it to C# and this gives me:

private bool _UserIsLoggedIn;

public bool UserIsLoggedIn
{
get { return _UserIsLoggedIn; }
set { _UserIsLoggedIn = value; }
}

However, I cannot access this property from the calling page.

Can anyone tell me where I am going wrong.

Regards
Aug 24 '07 #1
7 1201
On 24 A ustos, 13:44, Mick Walker <mick.wal...@privacy.netwrote:
Hi everyone,

My client is requiring me to convert an existing web app from VB.Net to
C# to become more inline with their existing codebase.

I am running into a problem when converting a usercontrol, basically the
usercontrol has a property which is set by the hosting page, to indicate
if a user is logged in or not. This controls the navigation menu which
the user see's.

In the VB version its just a matter of:
Private _UserIsLoggedIn As Boolean

Public Property UserIsLoggedIn() As Boolean
Get
Return _UserIsLoggedIn
End Get
Set(ByVal value As Boolean)
_UserIsLoggedIn = value
End Set
End Property

So I convert it to C# and this gives me:

private bool _UserIsLoggedIn;

public bool UserIsLoggedIn
{
get { return _UserIsLoggedIn; }
set { _UserIsLoggedIn = value; }
}

However, I cannot access this property from the calling page.

Can anyone tell me where I am going wrong.

Regards
----------------------------------------------------------------------------------------------------------------------------------------------------------

if you want to access this property after creating the instance of the
class.there must be nothing wrong.But if you want to access it wlthout
creating instance ,you must use 'static'.But convertion to c# and the
piece of code is true, you will access the property after creating the
instance..if you send more part of code ,we can help you more..
Best Regards
Hakan Fatih YILDIRIM
MCP

Aug 24 '07 #2
Do you cast the user control variable to the proper type ? Remember that C#
is always in "option strict on" mode (and you may want to do the same in
your VB projects).

---
Patrice

"Mick Walker" <mi*********@privacy.neta écrit dans le message de news:
5j*************@mid.individual.net...
Hi everyone,

My client is requiring me to convert an existing web app from VB.Net to C#
to become more inline with their existing codebase.

I am running into a problem when converting a usercontrol, basically the
usercontrol has a property which is set by the hosting page, to indicate
if a user is logged in or not. This controls the navigation menu which the
user see's.

In the VB version its just a matter of:
Private _UserIsLoggedIn As Boolean

Public Property UserIsLoggedIn() As Boolean
Get
Return _UserIsLoggedIn
End Get
Set(ByVal value As Boolean)
_UserIsLoggedIn = value
End Set
End Property

So I convert it to C# and this gives me:

private bool _UserIsLoggedIn;

public bool UserIsLoggedIn
{
get { return _UserIsLoggedIn; }
set { _UserIsLoggedIn = value; }
}

However, I cannot access this property from the calling page.

Can anyone tell me where I am going wrong.

Regards

Aug 24 '07 #3
"Mick Walker" wrote:
Hi everyone,

My client is requiring me to convert an existing web app from VB.Net to
C# to become more inline with their existing codebase.

I am running into a problem when converting a usercontrol, basically the
usercontrol has a property which is set by the hosting page, to indicate
if a user is logged in or not. This controls the navigation menu which
the user see's.

In the VB version its just a matter of:
Private _UserIsLoggedIn As Boolean

Public Property UserIsLoggedIn() As Boolean
Get
Return _UserIsLoggedIn
End Get
Set(ByVal value As Boolean)
_UserIsLoggedIn = value
End Set
End Property

So I convert it to C# and this gives me:

private bool _UserIsLoggedIn;

public bool UserIsLoggedIn
{
get { return _UserIsLoggedIn; }
set { _UserIsLoggedIn = value; }
}

However, I cannot access this property from the calling page.

Can anyone tell me where I am going wrong.

Regards
The answer is that you have changed the visibility of your property. In the
VB code you have defined it as Public, whereas you have used the private
keyword in the C# code. Change private to public and it will be visible.

HTH
Dan
Aug 24 '07 #4
On Aug 24, 6:44 am, Mick Walker <mick.wal...@privacy.netwrote:
Hi everyone,

My client is requiring me to convert an existing web app from VB.Net to
C# to become more inline with their existing codebase.

I am running into a problem when converting a usercontrol, basically the
usercontrol has a property which is set by the hosting page, to indicate
if a user is logged in or not. This controls the navigation menu which
the user see's.

In the VB version its just a matter of:
Private _UserIsLoggedIn As Boolean

Public Property UserIsLoggedIn() As Boolean
Get
Return _UserIsLoggedIn
End Get
Set(ByVal value As Boolean)
_UserIsLoggedIn = value
End Set
End Property

So I convert it to C# and this gives me:

private bool _UserIsLoggedIn;

public bool UserIsLoggedIn
{
get { return _UserIsLoggedIn; }
set { _UserIsLoggedIn = value; }
}

However, I cannot access this property from the calling page.

Can anyone tell me where I am going wrong.

Regards
I'd hate to state the obvious - but have you rebuilt the entire
project yet? Also, close all the tabs in the IDE and then reopen them.
C# and Asp.Net sometimes have difficulties keeping Intellisense up-to-
date. For C# you often must rebuild the project to get some changes to
show up, and with Asp.Net Intellisense sometimes won't refresh until
the code behind file has been reloaded.

Thanks,

Seth Rowe

Aug 24 '07 #5
That's not the case here - in both the VB and C# versions, the field is
private and the property is public.
--
David Anton
http://www.tangiblesoftwaresolutions.com
Convert between VB, C#, C++, and Java
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
"Dan Kelley" wrote:
"Mick Walker" wrote:
Hi everyone,

My client is requiring me to convert an existing web app from VB.Net to
C# to become more inline with their existing codebase.

I am running into a problem when converting a usercontrol, basically the
usercontrol has a property which is set by the hosting page, to indicate
if a user is logged in or not. This controls the navigation menu which
the user see's.

In the VB version its just a matter of:
Private _UserIsLoggedIn As Boolean

Public Property UserIsLoggedIn() As Boolean
Get
Return _UserIsLoggedIn
End Get
Set(ByVal value As Boolean)
_UserIsLoggedIn = value
End Set
End Property

So I convert it to C# and this gives me:

private bool _UserIsLoggedIn;

public bool UserIsLoggedIn
{
get { return _UserIsLoggedIn; }
set { _UserIsLoggedIn = value; }
}

However, I cannot access this property from the calling page.

Can anyone tell me where I am going wrong.

Regards

The answer is that you have changed the visibility of your property. In the
VB code you have defined it as Public, whereas you have used the private
keyword in the C# code. Change private to public and it will be visible.

HTH
Dan
Aug 24 '07 #6
Mick Walker wrote:
[...]
Here is the code for my user control if that helps:

[...]
public static bool UserIsLoggedIn
Um. Your original example showed an instance property, but the above
shows a static property.

First, you should know that a static property is shared among all
instances of the same class. Second, you should know that to access a
static property, you need to specify the class name, not an instance
name. That is:

Controls_uc_MainMenu.UserIsLoggedIn;

Rather than:

MainMenu1.UserIsLoggedIn;

Do you really intend for the properties to be static?

Pete
Aug 24 '07 #7
On Aug 24, 9:28 am, Dan Kelley <DanKel...@discussions.microsoft.com>
wrote:
"Mick Walker" wrote:
Hi everyone,
My client is requiring me to convert an existing web app from VB.Net to
C# to become more inline with their existing codebase.
I am running into a problem when converting a usercontrol, basically the
usercontrol has a property which is set by the hosting page, to indicate
if a user is logged in or not. This controls the navigation menu which
the user see's.
In the VB version its just a matter of:
Private _UserIsLoggedIn As Boolean
Public Property UserIsLoggedIn() As Boolean
Get
Return _UserIsLoggedIn
End Get
Set(ByVal value As Boolean)
_UserIsLoggedIn = value
End Set
End Property
So I convert it to C# and this gives me:
private bool _UserIsLoggedIn;
public bool UserIsLoggedIn
{
get { return _UserIsLoggedIn; }
set { _UserIsLoggedIn = value; }
}
However, I cannot access this property from the calling page.
Can anyone tell me where I am going wrong.
Regards

The answer is that you have changed the visibility of your property. In the
VB code you have defined it as Public, whereas you have used the private
keyword in the C# code. Change private to public and it will be visible.

HTH
Dan
You didn't read the code or the previous posts very well did you? The
OP defined the variable to be returned as private and the property as
public so everything is fine. Second, David Anton has already
corrected another poster who said the same thing you just did...

Thanks,

Seth Rowe

Aug 27 '07 #8

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

Similar topics

3
by: clintonG | last post by:
VB ===================== Public Interface IProcess ReadOnly Property Title( ) As String ... End Interface Public Class ProcessBase Inherits System.Web.UI.UserControl Implements IProcess
2
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation...
0
by: Dave Taylor | last post by:
I have a UserControl that has a bindable Object property named Value. The user can modify the Value property by changing a TextBox on the UserControl, and in the Validated event, I want to set...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
9
by: Fabrizio | last post by:
Hi to all, i'm pretty new on vb dotnet and I need your help. with Vb 6 i was able to create a routine and use a form as parameter : for example Routine1 (frm as form) frm.text1.value="TEST" end...
1
by: Michael Tissington | last post by:
I'm trying to convert a project from VS2003 to VS2005 After conversion all of my TagPrefix are not recognized in the body. <%@ Register TagPrefix="Oaklodge" TagName="Curve"...
7
by: guy | last post by:
Has anyone any experience of the conversion wizard for VB6 to VB2005? if so how good is it? also how does it handle database related conversions i.e is ADO converted to ADO.NET etc. the project...
1
by: musosdev | last post by:
Hi I've got a project I've just run through the conversion wizard, and it's giving me a few headaches. I've got a user control which has controls referrenced from its calling page...
7
by: Mick Walker | last post by:
Hi everyone, My client is requiring me to convert an existing web app from VB.Net to C# to become more inline with their existing codebase. I am running into a problem when converting a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
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...
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
jinu1996
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...
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...
0
agi2029
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 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.