Results 1 to 3 of 3

Thread: How do you pass values from a sub routine to another page?

  1. #1

    Thread Starter
    Member Comn8u's Avatar
    Join Date
    Jul 2004
    Posts
    35

    How do you pass values from a sub routine to another page?

    I'm using a calander that when a certain date is clicked, it will get the date from the sub routine and pass it to another page to be evaluated.

    Once this value is passed to the other page, it will be compared against the database to see if the date exist in the database. If it does, it will display the news and if it doesn't exist it will display a page stating "No News Found!".

    How would I pass this variable in .Net?

  2. #2
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    Why use another page ?

    To pass the values to another page you would either have to use the get method and attach the parameters to the url or use the post method or session the parameters.

    You could also cache the parameter but that seems like overkill to me.
    Last edited by venerable bede; Aug 2nd, 2004 at 05:40 AM.

    Parksie

  3. #3
    Lively Member
    Join Date
    Sep 2002
    Posts
    66
    How do you want this to work?

    1. select a date on a page and redirect to another page?
    -OR-
    2. have a pop up window display a calendar and refresh data on the parent window?

    1. on the SelectedDateChanged event do response.redirect("nextpage.aspx?d=" & myCalendar.SelectedDate.ToShortDateString). Then on nextpage.aspx in the page load event
    Dim D as Date = cDate(Request.QueryString("d"))

    2. on the main form place a link to open the popup window
    <a href="javascript:window.open('calendar.aspx')"></a>. google javascript: window.open to find addtional options when opening a new window. also put a hidden text box on the form <input type=hidden id=txtHide runat=server />

    on the SelectedDateChanged event put the following code
    VB Code:
    1. If calDate.SelectedDates.Count = 1 Then
    2.             Dim script As New System.Text.StringBuilder
    3.  
    4.             script.Append("<script language='javascript'>")
    5.             script.Append("window.opener.document.forms[0].txtHide.value='" & calDate.SelectedDate.ToShortDateString & "';")
    6.             script.Append("window.opener.document.forms[0].submit();")
    7.             script.Append("window.close();")
    8.             script.Append("</script>")
    9.             Page.RegisterStartupScript("SetDate", script.ToString)
    10. End If

    then on your page load event of the parent form:
    VB Code:
    1. if not page.ispostback then
    2.     'first time page loads
    3. else
    4.     if txtHide.Value <> "" Then
    5.         Try
    6.             Dim D as Date = cDate(txtHide.Value)
    7.         Catch
    8.             'value not a date
    9.         End Try
    10.         'query database for records to display
    11.     end if
    12. end if
    Jason Meckley
    Database Analyst
    WITF

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width