Jump to content

asp crosspage postback

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
dazzyg

dazzyg

    Newbie

  • Members
  • Pip
  • 8 posts
hi,
basically i have an simple asp.net web site with a registration page and then a summary page where the values from the registration page are posted in labels on the summary page. i use a master page for the layout
ive searched tried different code but they all seem to give me errors.

any help/pointers, i'd be greatful.

here is the code for the register page Register.aspx
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Register.aspx.vb" Inherits="Register" title="Register" %>


<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="~/Summary.aspx" runat="server" Style="z-index: 109; left: 261px; position: absolute;

        top: 328px" Text="Submit" />

And the summary page code Summary.aspx
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Summary.aspx.vb" Inherits="Summary" title="Untitled Page" %>

<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 summary page
summary.aspx.vb
Partial Class Search

    Inherits System.Web.UI.Page



If Not Page.PreviousPage Is Nothing Then

    Dim SourceTextBox As TextBox

    SourceTextBox = CType(PreviousPage.FindControl("txtFirstName"), _

        TextBox)

    If Not SourceTextBox Is Nothing Then

        lbl.FirstName = SourceTextBox.Text

    End If

End If


End Class


#2
amrosama

amrosama

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 8,671 posts
can you post the errors that you get plz
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
www.amrosama.com | the unholy methods of javascript

#3
dazzyg

dazzyg

    Newbie

  • Members
  • Pip
  • 8 posts
ive got rid of the errors and below is the code i now have but it is not printing the value of the textbox into the label on the summary page. Any ideas?

Register.aspx
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Register.aspx.vb" Inherits="Register" title="Register" %>

<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="~/Summary.aspx" runat="server" Style="z-index: 109; left: 261px; position: absolute;
        top: 328px" Text="Submit" />

Summary.aspx
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Summary.aspx.vb" Inherits="Summary" title="Summary" %>
<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 lastly the code behind the summary page (contained in summary.aspx.vb)
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


#4
imp0steur

imp0steur

    Newbie

  • Members
  • Pip
  • 8 posts
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

		Dim textBox = CType(PreviousPage.Page.FindControl("TextBox1"), TextBox)

		Label1.Text = textBox.Text

    End Sub


#5
angel

angel

    Newbie

  • Members
  • Pip
  • 1 posts
Hey hi!
I have the exact same problem with one of my pages in my application. Did you find the solution to the problem? It would be grateful if you posted the solution here!

#6
hkp

hkp

    Learning Programmer

  • Members
  • PipPipPip
  • 37 posts
On this link here is the good explanation of it. you can learn more about it..
Cross Page posting in ASP.NET 2.0

______________
Design a website