Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 27th, 2006, 12:55 PM
pbd22 pbd22 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2005
Posts: 779 pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 8 h 40 m 29 sec
Reputation Power: 6
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 ...

Reply With Quote
  #2  
Old January 27th, 2006, 02:08 PM
Memnoch1207 Memnoch1207 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 67 Memnoch1207 User rank is Sergeant (500 - 2000 Reputation Level)Memnoch1207 User rank is Sergeant (500 - 2000 Reputation Level)Memnoch1207 User rank is Sergeant (500 - 2000 Reputation Level)Memnoch1207 User rank is Sergeant (500 - 2000 Reputation Level)Memnoch1207 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 19 h 10 m 47 sec
Reputation Power: 14
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

Reply With Quote
  #3  
Old January 27th, 2006, 05:01 PM
pbd22 pbd22 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2005
Posts: 779 pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 8 h 40 m 29 sec
Reputation Power: 6
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.

Reply With Quote
  #4  
Old January 27th, 2006, 06:02 PM
pbd22 pbd22 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2005
Posts: 779 pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 8 h 40 m 29 sec
Reputation Power: 6
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...

Reply With Quote
  #5  
Old January 28th, 2006, 05:50 PM
pbd22 pbd22 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2005
Posts: 779 pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 8 h 40 m 29 sec
Reputation Power: 6
Arrow

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.

Reply With Quote
  #6  
Old January 30th, 2006, 11:30 AM
pbd22 pbd22 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2005
Posts: 779 pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level)pbd22 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 8 h 40 m 29 sec
Reputation Power: 6
anybody?

hi. does anybody have any idea on this one? thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Accessing objects in other forms??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT