Converting from java beans to c#

G

Guest

Hi,

I have an existing web application with java beans that I wanne migrate to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

....
<%@ page language="java" import="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
....
....
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<br>


Now I'm looking for a possibility to use/make some C# objects that behave
nearly the same way that java beans do. That means I want to use them in the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean..." the class is instantiated to webAppConstants and
can be used in the following html-code.

I tried the following solution that should give me an object from a session:

<%@ Page CodeBehind="Login.aspx.cs" Language="c#" AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
....

But Session is unknown. So how do I get access to the session? Or is what
would be another solution.

Thanks in advance for any help.

Stephen
 
K

Karl Seguin

I believe the problem is that you need to put your code in the page_load
event. ASP.Net, unlike classic ASP, is event driven. That is, there's an
page_load event which fires when the page first loads.

Try:

<script Language="c#" runat="server">
void page_load(){
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];

}
</script>


not really sure what the goal of: > <% ReportConstants reportConstants = new
ReportConstants(); %> is, since you are later overwriting it with the
session variable...why create a new instance only to have it overwritten?
but if you do need, it too should likely be placed in page_load.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
K

Kevin Spencer

This is kind of hard to say, but you're putting the cart before the horse
here. What I mean is that, rather than trying to make ASP.Net behave like
Java Beans, or ASP, which is the closest thing in the Microsoft family to
Java Beans. You need to be thinking more about how to accomplish WHAT you
accomplish in Java Beans with ASP.net, not HOW. That is, any programming
technology exists for basically the same purpose: To satisfy requirements,
or to "make something happen." Session State, for example, exists for the
purpose of maintaining state acrosss a single user Session in a stateless
HTTP environment. And indeed, ASP.Net has Session State, and it serves the
same purpose. But you're talking about nailing nails with a hammer gun
instead of a hammer, and you want to know where to hit the nail with the
hammer gun. The end is the same; the means is entirely different. In other
words, you need to either bite the proverbial bullet, and learn how to work
with the ASP.Net object model, or stick with what you know. If you hit nails
with a hammer gun, eventually, the gun breaks. On the other hand, if you use
a hammer gun as it was designed, you can drive a lot more nails in a lot
less time.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

Stephen H. said:
Hi,

I have an existing web application with java beans that I wanne migrate to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

...
<%@ page language="java" import="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<br>


Now I'm looking for a possibility to use/make some C# objects that behave
nearly the same way that java beans do. That means I want to use them in
the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean..." the class is instantiated to webAppConstants
and
can be used in the following html-code.

I tried the following solution that should give me an object from a
session:

<%@ Page CodeBehind="Login.aspx.cs" Language="c#" AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is what
would be another solution.

Thanks in advance for any help.

Stephen
 
G

Guest

Hi Karl,

I already tried this. The problem with this approach is that reportConstants
is only accessible in the scope of page_load. Even if I put the declaration
of reportConstants before the scope of page_load I get the runtime error
message "System.NullReferenceException: Object reference not set to an
instance of an object."

I figured out another solution for the static parts because now I know how
to access html tags from the codebehind file.

But there's still one remaining problem: How do I access parts in
JavaScript. The following line is an example how it worked with Java:
....
document.getElementById("database").value="<%
out.print(reportConstants.DBNAME); %>";
....

Bernd



Karl Seguin said:
I believe the problem is that you need to put your code in the page_load
event. ASP.Net, unlike classic ASP, is event driven. That is, there's an
page_load event which fires when the page first loads.

Try:

<script Language="c#" runat="server">
void page_load(){
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];

}
</script>


not really sure what the goal of: > <% ReportConstants reportConstants = new
ReportConstants(); %> is, since you are later overwriting it with the
session variable...why create a new instance only to have it overwritten?
but if you do need, it too should likely be placed in page_load.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Stephen H. said:
Hi,

I have an existing web application with java beans that I wanne migrate to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

...
<%@ page language="java" import="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<br>


Now I'm looking for a possibility to use/make some C# objects that behave
nearly the same way that java beans do. That means I want to use them in
the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean..." the class is instantiated to webAppConstants
and
can be used in the following html-code.

I tried the following solution that should give me an object from a
session:

<%@ Page CodeBehind="Login.aspx.cs" Language="c#" AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is what
would be another solution.

Thanks in advance for any help.

Stephen
 
G

Guest

Hi Kevin,

yes I have to learn more about ASP.Net. But metaphoric answers from people
who seem to come straight out of a DIY store are not really helpfull for
anybody.

Bernd


Kevin Spencer said:
This is kind of hard to say, but you're putting the cart before the horse
here. What I mean is that, rather than trying to make ASP.Net behave like
Java Beans, or ASP, which is the closest thing in the Microsoft family to
Java Beans. You need to be thinking more about how to accomplish WHAT you
accomplish in Java Beans with ASP.net, not HOW. That is, any programming
technology exists for basically the same purpose: To satisfy requirements,
or to "make something happen." Session State, for example, exists for the
purpose of maintaining state acrosss a single user Session in a stateless
HTTP environment. And indeed, ASP.Net has Session State, and it serves the
same purpose. But you're talking about nailing nails with a hammer gun
instead of a hammer, and you want to know where to hit the nail with the
hammer gun. The end is the same; the means is entirely different. In other
words, you need to either bite the proverbial bullet, and learn how to work
with the ASP.Net object model, or stick with what you know. If you hit nails
with a hammer gun, eventually, the gun breaks. On the other hand, if you use
a hammer gun as it was designed, you can drive a lot more nails in a lot
less time.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

Stephen H. said:
Hi,

I have an existing web application with java beans that I wanne migrate to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

...
<%@ page language="java" import="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<br>


Now I'm looking for a possibility to use/make some C# objects that behave
nearly the same way that java beans do. That means I want to use them in
the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean..." the class is instantiated to webAppConstants
and
can be used in the following html-code.

I tried the following solution that should give me an object from a
session:

<%@ Page CodeBehind="Login.aspx.cs" Language="c#" AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is what
would be another solution.

Thanks in advance for any help.

Stephen
 
K

Karl Seguin

As is often the case, I have to agree with what Kevin also posted.

one question is why does this need to be done in javascript?

what is "database" ? a textbox? then you should do it like:

<asp:textbox id="database" runat="server" />

and in your codebehind use:

database.Text = reportContants.DBNAME;


Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Stephen H. said:
Hi Karl,

I already tried this. The problem with this approach is that
reportConstants
is only accessible in the scope of page_load. Even if I put the
declaration
of reportConstants before the scope of page_load I get the runtime error
message "System.NullReferenceException: Object reference not set to an
instance of an object."

I figured out another solution for the static parts because now I know how
to access html tags from the codebehind file.

But there's still one remaining problem: How do I access parts in
JavaScript. The following line is an example how it worked with Java:
...
document.getElementById("database").value="<%
out.print(reportConstants.DBNAME); %>";
...

Bernd



Karl Seguin said:
I believe the problem is that you need to put your code in the page_load
event. ASP.Net, unlike classic ASP, is event driven. That is, there's
an
page_load event which fires when the page first loads.

Try:

<script Language="c#" runat="server">
void page_load(){
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];

}
</script>


not really sure what the goal of: > <% ReportConstants reportConstants =
new
ReportConstants(); %> is, since you are later overwriting it with the
session variable...why create a new instance only to have it overwritten?
but if you do need, it too should likely be placed in page_load.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Stephen H. said:
Hi,

I have an existing web application with java beans that I wanne migrate
to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

...
<%@ page language="java" import="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<br>


Now I'm looking for a possibility to use/make some C# objects that
behave
nearly the same way that java beans do. That means I want to use them
in
the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean..." the class is instantiated to
webAppConstants
and
can be used in the following html-code.

I tried the following solution that should give me an object from a
session:

<%@ Page CodeBehind="Login.aspx.cs" Language="c#"
AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is
what
would be another solution.

Thanks in advance for any help.

Stephen
 
S

Sean M

I really like this analogy.. can I quote you on it?


Kevin Spencer said:
This is kind of hard to say, but you're putting the cart before the horse
here. What I mean is that, rather than trying to make ASP.Net behave like
Java Beans, or ASP, which is the closest thing in the Microsoft family to
Java Beans. You need to be thinking more about how to accomplish WHAT you
accomplish in Java Beans with ASP.net, not HOW. That is, any programming
technology exists for basically the same purpose: To satisfy requirements,
or to "make something happen." Session State, for example, exists for the
purpose of maintaining state acrosss a single user Session in a stateless
HTTP environment. And indeed, ASP.Net has Session State, and it serves the
same purpose. But you're talking about nailing nails with a hammer gun
instead of a hammer, and you want to know where to hit the nail with the
hammer gun. The end is the same; the means is entirely different. In other
words, you need to either bite the proverbial bullet, and learn how to work
with the ASP.Net object model, or stick with what you know. If you hit nails
with a hammer gun, eventually, the gun breaks. On the other hand, if you use
a hammer gun as it was designed, you can drive a lot more nails in a lot
less time.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

Stephen H. said:
Hi,

I have an existing web application with java beans that I wanne migrate to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

...
<%@ page language="java" import="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<br>


Now I'm looking for a possibility to use/make some C# objects that behave
nearly the same way that java beans do. That means I want to use them in
the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean..." the class is instantiated to webAppConstants
and
can be used in the following html-code.

I tried the following solution that should give me an object from a
session:

<%@ Page CodeBehind="Login.aspx.cs" Language="c#" AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is what
would be another solution.

Thanks in advance for any help.

Stephen
 
K

Kevin Spencer

Why thank you Sean. All of my ramblings are copyright-free!

--
:-D,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

Sean M said:
I really like this analogy.. can I quote you on it?


Kevin Spencer said:
This is kind of hard to say, but you're putting the cart before the horse
here. What I mean is that, rather than trying to make ASP.Net behave like
Java Beans, or ASP, which is the closest thing in the Microsoft family to
Java Beans. You need to be thinking more about how to accomplish WHAT you
accomplish in Java Beans with ASP.net, not HOW. That is, any programming
technology exists for basically the same purpose: To satisfy
requirements,
or to "make something happen." Session State, for example, exists for the
purpose of maintaining state acrosss a single user Session in a stateless
HTTP environment. And indeed, ASP.Net has Session State, and it serves
the
same purpose. But you're talking about nailing nails with a hammer gun
instead of a hammer, and you want to know where to hit the nail with the
hammer gun. The end is the same; the means is entirely different. In
other
words, you need to either bite the proverbial bullet, and learn how to work
with the ASP.Net object model, or stick with what you know. If you hit nails
with a hammer gun, eventually, the gun breaks. On the other hand, if you use
a hammer gun as it was designed, you can drive a lot more nails in a lot
less time.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

Stephen H. said:
Hi,

I have an existing web application with java beans that I wanne migrate to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

...
<%@ page language="java" import="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<br>


Now I'm looking for a possibility to use/make some C# objects that behave
nearly the same way that java beans do. That means I want to use them
in
the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean..." the class is instantiated to webAppConstants
and
can be used in the following html-code.

I tried the following solution that should give me an object from a
session:

<%@ Page CodeBehind="Login.aspx.cs" Language="c#" AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is what
would be another solution.

Thanks in advance for any help.

Stephen
 
K

Kevin Spencer

Well, Stephen,

I wouldn't be here if I was a pure DIY guy! I'd be off somewhere ignoring
the rest of the world.

Notice that I did mention that you have the option of sticking with what you
know. Otherwise, you're goint o have to put on your thinking cap for a very
long time, along with the rest of use exploring this incredibly vast world
of .Net technology.

But, so you don't feel that I've completely abandoned you to your own
devices, I can provide you with a small piece of information regarding the
code you posted:
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is
what
would be another solution.

I would guess that it isn't Session that is "unknown." It looks like
Session["ReportConstants"] is null. I don't see where you've initialized it
prior to attempting to cast it as a ReportConstants class.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

Stephen H. said:
Hi Kevin,

yes I have to learn more about ASP.Net. But metaphoric answers from people
who seem to come straight out of a DIY store are not really helpfull for
anybody.

Bernd


Kevin Spencer said:
This is kind of hard to say, but you're putting the cart before the horse
here. What I mean is that, rather than trying to make ASP.Net behave like
Java Beans, or ASP, which is the closest thing in the Microsoft family to
Java Beans. You need to be thinking more about how to accomplish WHAT you
accomplish in Java Beans with ASP.net, not HOW. That is, any programming
technology exists for basically the same purpose: To satisfy
requirements,
or to "make something happen." Session State, for example, exists for the
purpose of maintaining state acrosss a single user Session in a stateless
HTTP environment. And indeed, ASP.Net has Session State, and it serves
the
same purpose. But you're talking about nailing nails with a hammer gun
instead of a hammer, and you want to know where to hit the nail with the
hammer gun. The end is the same; the means is entirely different. In
other
words, you need to either bite the proverbial bullet, and learn how to
work
with the ASP.Net object model, or stick with what you know. If you hit
nails
with a hammer gun, eventually, the gun breaks. On the other hand, if you
use
a hammer gun as it was designed, you can drive a lot more nails in a lot
less time.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

Stephen H. said:
Hi,

I have an existing web application with java beans that I wanne migrate
to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

...
<%@ page language="java" import="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<br>


Now I'm looking for a possibility to use/make some C# objects that
behave
nearly the same way that java beans do. That means I want to use them
in
the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean..." the class is instantiated to
webAppConstants
and
can be used in the following html-code.

I tried the following solution that should give me an object from a
session:

<%@ Page CodeBehind="Login.aspx.cs" Language="c#"
AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is
what
would be another solution.

Thanks in advance for any help.

Stephen
 
A

Amedee Van Gasse

Kevin Spencer shared this with us in
microsoft.public.dotnet.framework.aspnet:
Why thank you Sean. All of my ramblings are copyright-free!

# rambling starts here

Do you mean Public Domain, Open License, Shared License, Creative
Common License, Open Publication license, or some other licensing
scam^Wscheme?
;-)
 

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,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top