|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Accessing objects in other forms??
hi. i am new to OO concepts...
can somebody tell me how i access objects in other forms? so, i have form1. and it has text1, ddl1, label1, etc. I am in form2 and i want to ba able to access all the objects on form1. how do i do that? I am working in VB.NET/ASP.NET. here is the form i want to access (how do i access _subject and _location from outside this form?): thanks in advance! Code:
<%@ Page Language="VB" MasterPageFile="~/user_calendar/user_newitem.master" Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <form id="frm_newitem"> <table> <tr> <td valign="top" height="100%"> <table id="leftside" bgcolor="#eaeaea"> <tr> <td>Subject:</td> <td align="left"><input id="_subject" size="45" VALUE="" MAXLENGTH="99" /> </td> </tr> <tr> <td>Location:</td> <td align="left"><input id="_location" size="45" VALUE="" MAXLENGTH="99" /></td> </tr> ... etc, etc ... |
|
#2
|
|||
|
|||
|
You can't access form objects from another form in ASP.NET, because ASP is stateless.
To get the values from one form to another you can do one of the following: 1) Use Server.Transfer("somepage.aspx", True) 2) Store the values in a database to access them later. 3) Store the values in a session object.
__________________
Being educated does not make you intelligent |
|
#3
|
|||
|
|||
|
thanks
ok. thanks for the reply.
I researched sesssion objects and it looks like the way to go. Accordingly, I have the following as a script in one page: Code:
Public Sub Save_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
'page validation
If Context.Session("_subject").ToString() = "" Then
AlertMsg("Missing subject")
Return
End If
If Context.Session("_location").ToString() = "" Then
AlertMsg("Missing location")
Return
End If
If Context.Session("_monthStart").ToString() = "" Then
AlertMsg("Missing starting month")
Return
End If
and so on ....
the script attempts to access the values input in ("_subject", "_location", and "_monthStart") on another page. when it compiles, it stops at the first input box ("_subject") and i am told that a "NullReferenceException was Unhandled by the user code". what am i doing wrong here? thanks again. |
|
#4
|
|||
|
|||
|
oops...
just read that session objects are only good for browsers that support cookies and that isnt going to do for what i am trying to accomplish. need to appeal to all browsers so, i am going to hunt down alternative solutions...
|
|
#5
|
|||
|
|||
|
OK. i am still having problems with this one...
the core of my problem is that in Form1, i have input fields that accept various values. Form2 is a bar on the top of my page with "Save" on it (which saves the values that were input in Form1). So, without having the save button on the same page 1) I cant store values in the database to access them later 2) I cant access session objects 3) I am not quite sure what you mean by using Server.Transfer to communicate between forms Maybe i am overthinking this but i am stupped here. Is it possible to save values to a database in ASP.NET with the save button on a different form? if so, could somebody explain this - i'd really appreciate it. |
|
#6
|
|||
|
|||
|
anybody?
hi. does anybody have any idea on this one? thanks
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Software Design > Accessing objects in other forms?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|