posting from one form to another

Discussion in 'ASP .Net' started by rbutch@coair.com, Jan 26, 2005.

  1. Guest

    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...
     
    , Jan 26, 2005
    #1
    1. Advertising

  2. 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
     
    Jeppe Dige Jespersen, Jan 26, 2005
    #2
    1. Advertising

  3. 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
     
    Jeppe Dige Jespersen, Jan 26, 2005
    #3
  4. Guest

    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...
     
    , Jan 27, 2005
    #4
  5. > i do appreciate the info. outstanding and right on target.
    > thank you thank you


    Oh stop now. :)

    Jeppe
     
    Jeppe Dige Jespersen, Jan 27, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?ZWpz?=
    Replies:
    2
    Views:
    409
    =?Utf-8?B?ZWpz?=
    Nov 4, 2004
  2. Vishal
    Replies:
    3
    Views:
    309
    Ken Cox [Microsoft MVP]
    Dec 15, 2004
  3. loveNUNO
    Replies:
    2
    Views:
    933
    loveNUNO
    Nov 20, 2003
  4. Rob R. Ainscough
    Replies:
    3
    Views:
    340
    Rob R. Ainscough
    Jun 14, 2005
  5. Robert Cohen
    Replies:
    3
    Views:
    283
    Andrew Durstewitz
    Jul 15, 2003
Loading...

Share This Page