Navigating to a new aspx page and passing info to an embedded control

Last post 03-03-2008 9:20 AM by smcirish. 3 replies.

Sort Posts:

  • Navigating to a new aspx page and passing info to an embedded control

    03-02-2008, 2:55 PM
    • Member
      14 point Member
    • ross_petersen
    • Member since 08-06-2007, 11:04 AM
    • Midway Point, Tasmania, Australia
    • Posts 31

    Hi folks

    I have two aspx pages that are part of a web site.

    The first one (Sermons.aspx) contains a Gridview control that gets its data from a SQL Server Express 2005 DB and displays data from various fields in a view of a certain table.  One of the fields contains the path and filename of a particular mp3 file that varies from one row to the next (varchar). It also has a button control in the last column.

    Here is the source code for the first page:

     

    1    <%@ Page Language="VB" MasterPageFile="~/CCFMaster1.master" AutoEventWireup="false" CodeFile="Sermons.aspx.vb" Inherits="Sermons" title="Sermons" %>
    2    <asp:Content ID="Content1" ContentPlaceHolderID="bodyContentPlaceHolder" Runat="Server">
    3    
    4    If you have a look below, there is a list of recent sermons by date.&nbsp; There
    5        are also columns that include:<br />
    6        <ul>
    7            <li>the name of the speaker</li>
    8            <li>topic</li>
    9            <li>duration</li>
    10           <li>download link</li>
    11           <li>play button</li>
    12       </ul>
    13       <p>
    14       </p>
    15       <p>
    16       </p>
    17           <p></p>
    18       <ul>
    19       </ul>
    20       
    21           If you right - click on the download link and select "Save Target as ...", you can
    22           download the file to your computer.<asp:SqlDataSource ID="SqlDataSourceSermons" runat="server"
    23               ConnectionString="<%$ ConnectionStrings:CCFWebSiteDBConnectionString1 %>"
    24               OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [Sermon Date] AS Sermon_Date, [Speaker], [Topic], [Duration], [FileName], [File Name] AS File_Name FROM [vwSermons] ORDER BY [SermonDate]">
    25           </asp:SqlDataSource>
    26           <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    27               DataSourceID="SqlDataSourceSermons" Style="z-index: 102; left: 234px; position: absolute;
    28               top: 479px" AllowPaging="True" AllowSorting="True" Width="545px" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" Height="144px">
    29               <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
    30               <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
    31               <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
    32               <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
    33               <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
    34               <Columns>
    35                   <asp:BoundField DataField="Sermon_Date" HeaderText="Sermon_Date" SortExpression="Sermon_Date" />
    36                   <asp:BoundField DataField="Speaker" HeaderText="Speaker" SortExpression="Speaker" />
    37                   <asp:BoundField DataField="Topic" HeaderText="Topic" SortExpression="Topic" />
    38                   <asp:BoundField DataField="Duration" HeaderText="Duration" SortExpression="Duration" />
    39                   <asp:BoundField DataField="FileName" HeaderText="FileName" SortExpression="FileName"
    40                       Visible="False" />
    41                   <asp:BoundField DataField="File_Name" HeaderText="File_Name" SortExpression="File_Name"
    42                       Visible="False" />
    43                   <asp:HyperLinkField DataNavigateUrlFields="FileName" DataTextField="File_Name" HeaderText="Download" />
    44                   <asp:ButtonField ButtonType="Button" HeaderText="Play Sermon" Text="Play" />
    45               </Columns>
    46           </asp:GridView>
    47       
    48       <ul>
    49       </ul>
    50   </asp:Content>
    51   
    52   
    
     

     Here is the VB code associated with the same page:

    1    
    2    Partial Class Sermons
    3        Inherits System.Web.UI.Page
    4    
    5        Public Sub New()
    6    
    7        End Sub
    8    
    9        Protected Overrides Sub Finalize()
    10           MyBase.Finalize()
    11       End Sub
    12   
    13       Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
    14           If e.CommandName = "Play" Then
    15   
    16               Dim index As Integer = Convert.ToInt32(e.CommandArgument)
    17   
    18               Dim row As GridViewRow = GridView1.Rows(index)
    19   
    20               Server.Transfer("SermonsPlay.aspx")
    21   
    22           End If
    23       End Sub
    24   End Class
    25   
    
     

    The second page (SermonsPlay.aspx) has an embedded Quicktime control that at the moment has a hardcoded source mp3 file that plays successfully when I open that page.

    Finally, this is the source code for the second page:

     

    1    <%@ Page Language="VB" MasterPageFile="~/CCFMaster1.master" AutoEventWireup="false" CodeFile="SermonsPlay.aspx.vb" Inherits="SermonsPlay" title="Play Sermon" %>
    2    
    3    
    4    <asp:Content ID="Content1" ContentPlaceHolderID="bodyContentPlaceHolder" Runat="Server">
    5        <strong><em><span style="font-size: 24pt; text-decoration: underline">Play Sermon</span></em></strong><br />
    6        <br />
    7        <br />
    8        &nbsp;
    9        <embed 
    10           src="Sermons/30Sept2007.mp3" align="middle">
    11       </embed>
    12   </asp:Content>
    13   
    14   
    
     

    What I want to do is when a button on a particular row in the gridview control on the first page is clicked is for the first page to navigate to the next page and play the sound file.  However, I cannot figure how to pass the path of the sound file to the second page so that the Quicktime control will play that mp3 file.

    If anybody can explain how this can be done, I would really appreciate it.

    Kind regards

    Ross

    Kind regards


    Ross
  • Re: Navigating to a new aspx page and passing info to an embedded control

    03-03-2008, 5:04 AM
    Answer
    • Contributor
      4,518 point Contributor
    • tompy_nation
    • Member since 02-28-2007, 10:45 AM
    • Gent
    • Posts 1,155

    If you want to pass a value to another page use this:

    Response.Redirect("yourPage.aspx?passedValue=" + strValueYouWanttoPass);

     

    Then in the PageLoad  of yourPage.aspx read in the value that is being passed:

    if (!IsPostBack)

    {

    string passedValue = Request.QueryString["passedValue"];

    }

    Don't forget to click "Mark as Answer" on the post that helped you.
    Filed under:
  • Re: Navigating to a new aspx page and passing info to an embedded control

    03-03-2008, 8:10 AM
    • Member
      30 point Member
    • SZachmann
    • Member since 03-03-2008, 12:58 PM
    • Posts 5

    I've played around a little bit with hosting some of my own mp3 files and unless I'm remembering incorrectly you should be able to just have the link be the file itself (http://www.yoursite.com/yoursong.mp3) and if the client has Quicktime it will automatically just start playing in the browser.  ProjectPlaylist.com is a good example of a site that does this a lot.  I can't remember if you have to change anything in IIS to make this work but I don't think you do.

  • Re: Navigating to a new aspx page and passing info to an embedded control

    03-03-2008, 9:20 AM
    • Member
      600 point Member
    • smcirish
    • Member since 04-16-2007, 5:27 PM
    • Texas
    • Posts 368

    On Click, can you load a value into a Session variable?

     Private Sub back_button_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles back_button.Click

            '=== Back to Dept_entry_main  ===
            Session("back_click") = "Y"
            Response.Redirect("Dept_entry_main.aspx")

     End Sub

     

     

    ~ Remember To Mark The Posts Which Helped You As The ANSWER ~
    Filed under:
Page 1 of 1 (4 items)