Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass variables from one mboile form to another

Status
Not open for further replies.

leearach2004

Technical User
Dec 8, 2005
86
GB
Hi there I have 2 mobilr forms in one aspx file, I have 5 labels on the one form displaying some information in then need when a command button is pressed to go to the next form and display the same information but in text boxs. How do you pass text from on mobilr form to another using vb language.
Anyone help cant find much on the net about mobile forms, lots on normal forms.

lee
 
you can use a session to do that. if you want a popup form you will have to use java, if you don't want a popup form use response.redirect with sessions.

 
hi there thanks alot thats what i need to do dotn need a popup form just a normal second form, i read the link that u posted but that dosent tell u how to pass data from one form to another, how do i use this reponse.redirect with sessions to ransfer the data from 5 labels on one form to five textboxs on another form, can you help you sound like you have the answer that I have been looking for
I hope so

lee
 
You don't need session variables to pass values from one form to the other, because you can host several subforms on a mobile form. You just make one active at a time. Below is an example of a loan calculator that passes calculated data from one form (Form1) to a second form (Form2).

Code:
<body>
    <mobile:Form id="Form1" runat="server" Title="Loan Calculator">        
        
        <mobile:Panel ID="Panel1" Runat="server">
            
            <mobile:Label Runat="server" ID="lbl1">Principal</mobile:Label><mobile:TextBox id="txtPrincipal" Runat="Server"></mobile:TextBox>
            <mobile:Label Runat="server" ID="lbl2">Term</mobile:Label><mobile:TextBox id="txtTerm" Runat="Server"></mobile:TextBox>
            <mobile:Label Runat="server" ID="lbl3">Rate</mobile:Label><mobile:TextBox id="txtRate" Runat="Server"></mobile:TextBox>
            <mobile:Command id="cmdCalculate" runat="server" OnClick="cmdCalculate_Click">Calculate</mobile:Command>
        </mobile:Panel>
    </mobile:Form>
    <mobile:Form ID="Form2" Runat="server">
        <mobile:Label ID="lblLoanDetails" Runat="server">Loan Details</mobile:Label>
        <mobile:Label ID="lblPayment" Runat="server">Payment</mobile:Label>
        <mobile:Command ID="cmdReturn" Runat="server" OnClick="cmdReturn_Click">Return to Calculator</mobile:Command>
    </mobile:Form>
</body>

Code:
protected void cmdCalculate_Click(object sender, EventArgs e)
    {
        Double principal = Convert.ToDouble(this.txtPrincipal.Text);
        Double apr = Convert.ToDouble(this.txtRate.Text);
        Double monthlyInterest = (Double)(apr / (12 * 100));
        Double termInMonths = Convert.ToDouble(this.txtTerm.Text) * 12;
        Double monthlyPayment;
        monthlyPayment = Microsoft.VisualBasic.Financial.Pmt(
           monthlyInterest, termInMonths, -principal, 0,
           Microsoft.VisualBasic.DueDate.BegOfPeriod);
        this.ActiveForm = this.Form2;
        this.lblLoanDetails.Text = principal.ToString("C0") + " @ " +
          apr.ToString() + "% for " + this.txtTerm.Text + " years";
        this.lblPayment.Text = monthlyPayment.ToString("C");

    }
    protected void cmdReturn_Click(object sender, EventArgs e)
    {
        this.ActiveForm = this.Form1;
    }
 
thanks alot thats what I was looking for just made my day never thought it would be that easy with all the information other people have told me
thanks alot much apreciated
lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top