Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

ASP.NET Query

  • 24-11-2008 08:21PM
    #1
    Closed Accounts Posts: 121 ✭✭


    Hi,
    Ive got a asp.net website with a master page for the layout - a page where a user types in there name and then it is displayed on a different page.

    below is the code i have. im not getting any errors but its not displaying the name when the last page opens

    details page
    <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Details.aspx.vb" Inherits="Details" title="Details" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <br />
        <asp:TextBox ID="txtFirstName" runat="server" Style="z-index: 100; left: 303px; position: absolute;
            top: 172px"></asp:TextBox>
        <br />
    <asp:Button ID="btnSubmit" PostBackUrl="~/Results.aspx" runat="server" Style="z-index: 109; left: 261px; position: absolute;
            top: 328px" Text="Submit" />
    


    and the results page
    <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Results.aspx.vb" Inherits="Results" title="Results" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="lblFirstName" runat="server" Style="z-index: 106; left: 181px; position: absolute;
            top: 278px" Text="FirstName"></asp:Label>
    
    </asp:Content>
    

    and the code behind the results page in the results.aspx.vb page
    Partial Class Summary
        Inherits System.Web.UI.Page
    
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        End Sub
    
    
        Protected Sub lblFirstName_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblFirstName.Load
            lblFirstName.Text = Request.Form("Content1$ContentPlaceHolder1$txtFirstName")
        End Sub
    End Class
    

    thanks


Comments

  • Registered Users, Registered Users 2 Posts: 610 ✭✭✭nialo


    Content1$ContentPlaceHolder1$ is not going to be the actual code that is within the webform. when your first page loads. right click it and view the source. find out what Content1$ContentPlaceHolder1$ actually is and replace it with this in your results page.


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    in the results.aspx

    In the Page_Load event try the following

    lblFirstname.Text = Request.Form("txtFirstName")


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Or

    If Not Page.PreviousPage Is Nothing Then
    Dim SourceTextBox As TextBox
    SourceTextBox = CType(PreviousPage.FindControl("txtFirstName"), _
    TextBox)
    If Not SourceTextBox Is Nothing Then
    lblFirstname.Text = SourceTextBox.Text
    End If
    End If

    Just as a matter of interest why are you doing cross page posting when a simple submit to the original page will work?


  • Closed Accounts Posts: 121 ✭✭Puff Puff Pass


    nialo wrote: »
    Content1$ContentPlaceHolder1$ is not going to be the actual code that is within the webform. when your first page loads. right click it and view the source. find out what Content1$ContentPlaceHolder1$ actually is and replace it with this in your results page.
    thanks nialo, your answer worked.
    in the page load function for the results page i simply used

    lblFirstName.Text = Request.Form("ct100$ContentPlaceHolder1$txtFirstName")

    works perfect,
    thanks


Advertisement