posting from one form to another

R

rbutch

hey guys, i may be totally in left field on this, but i'll try to explain.
using a web form and VB.net.

a simple text box control.
and added an 'onclick' event to bring up another aspx form with a calendar.
works fine.

txtCal.Attributes.Add("onclick", "window.open('MyCalendar.aspx',null,'height=200,width=250,top=200,left=200,status=no,resizable=no,scrollbars=no,toolbar=no,location=no,menubar=no');")

what im trying to do is after the (floating calendar) comes up and the user chooses a date, the calendar should close.
and it does.

i added that to the "selectionChanged" event.
Calendar1.Attributes.Add("onclick", "window.close('MyCalendar.aspx');")
now, my goal here is to have that date populate the original Default Form.

i can add it to the session state.

Session("mydate") = Calendar1.SelectedDate

and that works fine as well and the calendar closes.

now to the real question. there is nothing on the original form to trigger that update since it's just sitting there on the screen.

and using.
Response.Redirect("Default.aspx")
doesnt work either since it brings the "Default.aspx" up in the actual calendar window.
but i can refresh that "Default" screen and the value is there, it's just simply showing the same state as what it was when i brought the calendar up.

so, am i way off base on trying to do it this way?
do i need to go the javascript route on this?
it seems so close if only there was some event that would trigger the original form to show the session variable.

thanks again for any help
rik




**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
J

Jeppe Dige Jespersen

I'll give it a shot....

Two forms: "Default.aspx" and "Calendar.aspx", each with their own .vb
code-behind file.

** Default.aspx <body> only **
<body><form id="Form1" method="post" runat="server"><INPUT
onclick="window.open
'Calendar.aspx',null,'height=200,width=250,top=200,left=200,status=no,resizable=no,scrollbars=no,toolbar=no,location=no,menubar=no');"
type="button" value="Button")><asp:Label id=Label1 runat="server"
/></form></body>


** Default.aspx.vb **
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Label1.Text = Session("date")
End Sub


** Calender.aspx <body> only **
<body><form id="Form1" method="post" runat="server"><asp:Calendar
id="Calendar1" runat="server" /></form></body>


** Calendar.aspx.vb **
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Page.IsPostBack Then
Response.Write("<script
language='javascript'>opener.location.reload();window.close('Calendar.aspx');</script>")
End If
End Sub

Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Calendar1.SelectionChanged
Session("date") = Calendar1.SelectedDate.ToLongDateString
End Sub

---the end --- :)

Hope that helps you out.....
Jeppe Jespersen
 
J

Jeppe Dige Jespersen

I goofed it up. DOH!

** Calendar.aspx.vb SHOULD be.... **

Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Calendar1.SelectionChanged
Session("date") = Calendar1.SelectedDate.ToLongDateString
Response.Write("<script
language='javascript'>opener.location.reload();window.close('Calendar.aspx');</script>")
End Sub

********************

In the code I posted just a minute ago, you cannot change the month without
the window closing. My bad.

Jeppe
 
R

rbutch

dude, that was the missing piece....

Response.Write("<script language='javascript'>opener.location.reload();window.close('Calendar.aspx');</script>")


absolutely that was all that was needed to cause the original form to reload.
everything else was in place.

coming from a non classic asp background, i'm severly deficient in anything resembling javascript.
but, in asp.net, i'm finding i need it more and more everyday.

i do appreciate the info. outstanding and right on target.
thank you thank you
rik

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top