Windows App v. ASP.Net App

S

Scott M.

The difference is that you are referring to 2 different listbox controls.
In a Windows Forms project, you are using the System.Windows.Forms.Listbox
control, which has an Items collection that exposes an Add method. This Add
method only allows Objects to be passed to it and a Folder is an Object, so
your syntax: lstFolders.Items.Add(folder); works just fine.

In an ASP.NET Web Project, you are using the
System.Web.UI.WebConrols.Listbox control, which also exposes an Items
collection that has an Add method as well. But, this Add method only
accepts ListItem objects or Strings. Since your Folder is not a ListItem
object, you must treat it as a string, hence ToString is needed.

The bottom line is that in an ASP.NET Web application, you will be using
different controls than in a Windows Forms application and although you will
see controls that look the same in both kinds of projects, they are not the
same controls and may have differences between them.

-Scott
 
G

Garth Wells

I'm working with an SDK from a commercial software
vendor and am using a sample Windows Application
written in C# to learn the SDK (they do not have an
ASP.Net example). I need to create an ASP.Net Web
Application and have noticed that I'm having to ToString
the object references. For example, the following works
in the samle code:


// Get the list from the server
foreach (LoanFolder folder in Globals.Session.Loans.Folders)
lstFolders.Items.Add(folder);



but it must be converted to this:


// Get the list from the server
foreach (LoanFolder folder in Globals.Session.Loans.Folders)
lstFolders.Items.Add(folder.ToString());

to work in ASP.Net. So this call from the SDK:


LoanIdentityList loans = parentFolder.GetContents();


turns into:


LoanIdentityList loans =
Globals.Session.Loans.Folders[parentFolder].GetContents();


What's the fundamental difference between the two types of
applications that require the changes?


Thanks
 
A

Anon-E-Moose

The bottom line is that in an ASP.NET Web application, you will be
using different controls than in a Windows Forms application and
although you will see controls that look the same in both kinds of
projects, they are not the same controls and may have differences
between them.

Also I believe ASP.NET controls are thread-safe whereas Winform controls
are not ... tho there is a lot less threading on the web than in a Winforms
app.
 
S

Scott M.

Methods may take in none, one or many different sets of arguments
(overloading), but methods can only RETURN one type. So, if GetContents()
returns a LoanIdentity type, then that is the only thing it can return.

Garth Wells said:
Thanks for the quick reply. I've only done ASP/ASP.Net development, so
converting the app with the limited samples and poor documentation is
difficult.

Let me ask you one more thing. The following:


LoanIdentityList loans = parentFolder.GetContents();


returns a GUID in the windows app, but the converted line returns
a string.

LoanIdentityList loans =
Globals.Session.Loans.Folders[parentFolder].GetContents();

and the list is loaded with:

foreach (LoanIdentity id in loans)
lstLoans.Items.Add(id.ToString)

Obviously GetContents() returns LoanIdentity, but whats the best way to
tell if
it
returns any other values. The documentation does not describe the
collections
and
methods.

Thanks Again.




Scott M. said:
The difference is that you are referring to 2 different listbox controls.
In a Windows Forms project, you are using the
System.Windows.Forms.Listbox
control, which has an Items collection that exposes an Add method. This
Add
method only allows Objects to be passed to it and a Folder is an Object,
so
your syntax: lstFolders.Items.Add(folder); works just fine.

In an ASP.NET Web Project, you are using the
System.Web.UI.WebConrols.Listbox control, which also exposes an Items
collection that has an Add method as well. But, this Add method only
accepts ListItem objects or Strings. Since your Folder is not a ListItem
object, you must treat it as a string, hence ToString is needed.

The bottom line is that in an ASP.NET Web application, you will be using
different controls than in a Windows Forms application and although you
will
see controls that look the same in both kinds of projects, they are not
the
same controls and may have differences between them.

-Scott


Garth Wells said:
I'm working with an SDK from a commercial software
vendor and am using a sample Windows Application
written in C# to learn the SDK (they do not have an
ASP.Net example). I need to create an ASP.Net Web
Application and have noticed that I'm having to ToString
the object references. For example, the following works
in the samle code:


// Get the list from the server
foreach (LoanFolder folder in Globals.Session.Loans.Folders)
lstFolders.Items.Add(folder);



but it must be converted to this:


// Get the list from the server
foreach (LoanFolder folder in Globals.Session.Loans.Folders)
lstFolders.Items.Add(folder.ToString());

to work in ASP.Net. So this call from the SDK:


LoanIdentityList loans = parentFolder.GetContents();


turns into:


LoanIdentityList loans =
Globals.Session.Loans.Folders[parentFolder].GetContents();


What's the fundamental difference between the two types of
applications that require the changes?


Thanks
 
G

Garth Wells

Thanks for the quick reply. I've only done ASP/ASP.Net development, so
converting the app with the limited samples and poor documentation is
difficult.

Let me ask you one more thing. The following:


LoanIdentityList loans = parentFolder.GetContents();


returns a GUID in the windows app, but the converted line returns
a string.

LoanIdentityList loans =
Globals.Session.Loans.Folders[parentFolder].GetContents();

and the list is loaded with:

foreach (LoanIdentity id in loans)
lstLoans.Items.Add(id.ToString)

Obviously GetContents() returns LoanIdentity, but whats the best way to tell if
it
returns any other values. The documentation does not describe the collections
and
methods.

Thanks Again.




Scott M. said:
The difference is that you are referring to 2 different listbox controls.
In a Windows Forms project, you are using the System.Windows.Forms.Listbox
control, which has an Items collection that exposes an Add method. This Add
method only allows Objects to be passed to it and a Folder is an Object, so
your syntax: lstFolders.Items.Add(folder); works just fine.

In an ASP.NET Web Project, you are using the
System.Web.UI.WebConrols.Listbox control, which also exposes an Items
collection that has an Add method as well. But, this Add method only
accepts ListItem objects or Strings. Since your Folder is not a ListItem
object, you must treat it as a string, hence ToString is needed.

The bottom line is that in an ASP.NET Web application, you will be using
different controls than in a Windows Forms application and although you will
see controls that look the same in both kinds of projects, they are not the
same controls and may have differences between them.

-Scott


Garth Wells said:
I'm working with an SDK from a commercial software
vendor and am using a sample Windows Application
written in C# to learn the SDK (they do not have an
ASP.Net example). I need to create an ASP.Net Web
Application and have noticed that I'm having to ToString
the object references. For example, the following works
in the samle code:


// Get the list from the server
foreach (LoanFolder folder in Globals.Session.Loans.Folders)
lstFolders.Items.Add(folder);



but it must be converted to this:


// Get the list from the server
foreach (LoanFolder folder in Globals.Session.Loans.Folders)
lstFolders.Items.Add(folder.ToString());

to work in ASP.Net. So this call from the SDK:


LoanIdentityList loans = parentFolder.GetContents();


turns into:


LoanIdentityList loans =
Globals.Session.Loans.Folders[parentFolder].GetContents();


What's the fundamental difference between the two types of
applications that require the changes?


Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top