[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

How pass variables between web forms?

Don Schilling

1/23/2003 12:19:00 AM

How do I pass pass a drop down list box selected value from a web form that
contians code behind to another web form that contains code behind?

I've read several ms docs that state if I pass from code behind to code
behind, I must complie both behind pages into one dll. I'd rather not do
this. I've found good articles on passing InLine to InLine. But they seem
to fail when the receiving page has any type of code behind involved.

Is there a way to pass from in-line to receiving in-line when the receiving
is using code behind for other things?

Example, this works until last receiving page line:
I put ClassName="FirstPageClass"
and
Public ReadOnly Property FirstName() As String
Get
Return first.Text
End Get
End Property
into the sending page.

This is the receiving page:
<%@ Reference Page="SendOne.aspx" %>
<HTML>
<HEAD>
<script runat="server">

Dim fp As FirstPageClass

Sub Page_Load()
If Not IsPostBack Then
fp = CType(Context.Handler, FirstPageClass)
End If
End Sub

</script>
</HEAD>
<body>
<form id="Form1" runat="server">
Hello
<%=fp.FirstName%>
<%=fp.LastName%>
</form>
</body>
</HTML>

This works fine until I add the code behind line:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ROne.aspx.vb"
Inherits="MI3.ROne" %>
The code behind will be needed for a datagrid.

Then I get:
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.<%=fp.FirstName%>

How are others handeling gathering 6 or 7 inputs from a user, then
displaying some db results? This would look terrible if the data grid
appeared underneath all the form questions on the same page.
Thaks


6 Answers

Abhijeet Dev

1/23/2003 11:28:00 AM

0

u can use session variables to store it, even if u r using code behind

Abhijeet Dev

"Don Schilling" <notreal@fake.com> wrote in message
news:ukJSZ0mwCHA.2304@TK2MSFTNGP10...
> How do I pass pass a drop down list box selected value from a web form
that
> contians code behind to another web form that contains code behind?
>
> I've read several ms docs that state if I pass from code behind to code
> behind, I must complie both behind pages into one dll. I'd rather not do
> this. I've found good articles on passing InLine to InLine. But they
seem
> to fail when the receiving page has any type of code behind involved.
>
> Is there a way to pass from in-line to receiving in-line when the
receiving
> is using code behind for other things?
>
> Example, this works until last receiving page line:
> I put ClassName="FirstPageClass"
> and
> Public ReadOnly Property FirstName() As String
> Get
> Return first.Text
> End Get
> End Property
> into the sending page.
>
> This is the receiving page:
> <%@ Reference Page="SendOne.aspx" %>
> <HTML>
> <HEAD>
> <script runat="server">
>
> Dim fp As FirstPageClass
>
> Sub Page_Load()
> If Not IsPostBack Then
> fp = CType(Context.Handler, FirstPageClass)
> End If
> End Sub
>
> </script>
> </HEAD>
> <body>
> <form id="Form1" runat="server">
> Hello
> <%=fp.FirstName%>
> <%=fp.LastName%>
> </form>
> </body>
> </HTML>
>
> This works fine until I add the code behind line:
> <%@ Page Language="vb" AutoEventWireup="false" Codebehind="ROne.aspx.vb"
> Inherits="MI3.ROne" %>
> The code behind will be needed for a datagrid.
>
> Then I get:
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.<%=fp.FirstName%>
>
> How are others handeling gathering 6 or 7 inputs from a user, then
> displaying some db results? This would look terrible if the data grid
> appeared underneath all the form questions on the same page.
> Thaks
>
>


Don Schilling

1/23/2003 2:54:00 PM

0

Yes. But Session vaiables have thier own problems.
I'm looking for the best practice way to replace asp
request.form("name").value


"Abhijeet Dev" <abhijeet_dev@hotmail.com> wrote in message
news:eP1xtpswCHA.2636@TK2MSFTNGP12...
> u can use session variables to store it, even if u r using code behind
>
> Abhijeet Dev
>
> "Don Schilling" <notreal@fake.com> wrote in message
> news:ukJSZ0mwCHA.2304@TK2MSFTNGP10...
> > How do I pass pass a drop down list box selected value from a web form
> that
> > contians code behind to another web form that contains code behind?
> >
> > I've read several ms docs that state if I pass from code behind to code
> > behind, I must complie both behind pages into one dll. I'd rather not
do
> > this. I've found good articles on passing InLine to InLine. But they
> seem
> > to fail when the receiving page has any type of code behind involved.
> >
> > Is there a way to pass from in-line to receiving in-line when the
> receiving
> > is using code behind for other things?
> >
> > Example, this works until last receiving page line:
> > I put ClassName="FirstPageClass"
> > and
> > Public ReadOnly Property FirstName() As String
> > Get
> > Return first.Text
> > End Get
> > End Property
> > into the sending page.
> >
> > This is the receiving page:
> > <%@ Reference Page="SendOne.aspx" %>
> > <HTML>
> > <HEAD>
> > <script runat="server">
> >
> > Dim fp As FirstPageClass
> >
> > Sub Page_Load()
> > If Not IsPostBack Then
> > fp = CType(Context.Handler, FirstPageClass)
> > End If
> > End Sub
> >
> > </script>
> > </HEAD>
> > <body>
> > <form id="Form1" runat="server">
> > Hello
> > <%=fp.FirstName%>
> > <%=fp.LastName%>
> > </form>
> > </body>
> > </HTML>
> >
> > This works fine until I add the code behind line:
> > <%@ Page Language="vb" AutoEventWireup="false" Codebehind="ROne.aspx.vb"
> > Inherits="MI3.ROne" %>
> > The code behind will be needed for a datagrid.
> >
> > Then I get:
> > Exception Details: System.NullReferenceException: Object reference not
set
> > to an instance of an object.<%=fp.FirstName%>
> >
> > How are others handeling gathering 6 or 7 inputs from a user, then
> > displaying some db results? This would look terrible if the data grid
> > appeared underneath all the form questions on the same page.
> > Thaks
> >
> >
>
>


Abhijeet Dev

1/23/2003 3:15:00 PM

0

http://www.dotnetbips.com/displayarticle....

"Don Schilling" <notreal@fake.com> wrote in message
news:eUuWLduwCHA.968@TK2MSFTNGP12...
> Yes. But Session vaiables have thier own problems.
> I'm looking for the best practice way to replace asp
> request.form("name").value
>
>


Don Schilling

1/23/2003 3:35:00 PM

0

I have this one. Thanks anyway.



"Abhijeet Dev" <abhijeet_dev@hotmail.com> wrote in message
news:ONQbuouwCHA.2396@TK2MSFTNGP10...
> http://www.dotnetbips.com/displayarticle....
>
> "Don Schilling" <notreal@fake.com> wrote in message
> news:eUuWLduwCHA.968@TK2MSFTNGP12...
> > Yes. But Session vaiables have thier own problems.
> > I'm looking for the best practice way to replace asp
> > request.form("name").value
> >
> >
>
>


Robert Herman

1/23/2003 7:50:00 PM

0

So what's the answer? Does server.transfer work?
>-----Original Message-----
>http://www.dotnetbips.com/displayarticle....
>
>"Don Schilling" <notreal@fake.com> wrote in message
>news:eUuWLduwCHA.968@TK2MSFTNGP12...
>> Yes. But Session vaiables have thier own problems.
>> I'm looking for the best practice way to replace asp
>> request.form("name").value
>>
>>
>
>
>.
>

Don Schilling

1/24/2003 5:18:00 PM

0

No answer yet. I was hoping someone would post one. I've gotten
server.transfer to work inline from aspx to aspx. It still worked when I
added code behind to the sending page. But as soon as I add codebehind to
the receiving page it breaks. I havent tried the codebehind to codebehind
solution becuase of the joint complie issue. For the moment, I stuck my
values in as a Context.Item. (see below) But I havent researched enough to
know the memory, overhead, and problems involved with this. Most of the
answers I've found on the web are very poor. Everything from writing the
variables out to files, cookies, or into databases. One different work
arounds was to use the same web page with two different pannels and avoid
the whole passing of variables problem. One panel with questions, one with
the results. Only have one visable at a time. This will create a lot of
grafic layout problems though. I'm really looking for a high production,
high use replacement to request.form("stuff").values.

Context Example:
Send in codebehind = Context.Items("Name") = name.txt
Server.Transfer
Receive in codebehind = myvar = Context.Items("Name")




"Robert Herman" <rherman@treehouse-productions.com> wrote in message
news:01ec01c2c310$4f2b0e30$d4f82ecf@TK2MSFTNGXA11...
> So what's the answer? Does server.transfer work?
> >-----Original Message-----
> >http://www.dotnetbips.com/displayarticle....
> >
> >"Don Schilling" <notreal@fake.com> wrote in message
> >news:eUuWLduwCHA.968@TK2MSFTNGP12...
> >> Yes. But Session vaiables have thier own problems.
> >> I'm looking for the best practice way to replace asp
> >> request.form("name").value
> >>
> >>
> >
> >
> >.
> >