I'm doing a little project.
I want to manipulate textbox of Form2.aspx
from my Default.aspx
here's my code
Public Class _Default
Inherits System.Web.UI.Page
Dim stats As Form2 = New Form2()
Dim sim As Simulation = New Simulation()
Dim unique(5) As Integer
Dim gagnant(5) As Integer
Dim taux(5) As Integer
Dim tsS As DateTime = New DateTime()
Dim tsF As TimeSpan = New TimeSpan()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Public Sub Simuler_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'Prise du temps pour le calcul du temps de l'Exécution
tsS = DateTime.Now
'Générer aléatoirement le billet Gagnant
unique = sim.GenerateGagnant()
'Afficher les numéros du billet gagnant
stats.numG1.Text = unique(0).ToString()
stats.numG2.Text = unique(1).ToString()
stats.numG3.Text = unique(2).ToString()
stats.numG4.Text = unique(3).ToString()
stats.numG5.Text = unique(4).ToString()
stats.numG6.Text = unique(5).ToString()
'Générer les billets des acheteurs
Dim nbBillet As Integer = sim.GenerateBillet(Integer.Parse(tbX.Text), Integer.Parse(tbY.Text), Integer.Parse(tbS.Text))
'Comparer les billets des acheteurs au billet gagnant et afficher les résultats
gagnant = sim.comparer()
'Prendre en mémoire les taux (%) en entrée
taux(0) = Integer.Parse(tbP1.Text)
taux(1) = Integer.Parse(tbP2.Text)
taux(2) = Integer.Parse(tbP3.Text)
taux(3) = Integer.Parse(tbP4.Text)
taux(4) = Integer.Parse(tbP5.Text)
taux(5) = Integer.Parse(tbP6.Text)
'Récupérer l'historique du fichier et l'afficher
Dim s As String = sim.lireFic()
'historique.rtbHisto.Text = s
'Récupérer le prix unitaire des billets en entrée
Dim prix As Integer = Integer.Parse(tbPrix.Text)
'Calcul des gains bruts de la Loto et les afficher
Dim gains As Integer = prix * nbBillet
stats.tbGains.Text = gains.ToString()
'Calcul et affichage en $ des remises pour chaque catégorie
'taux * les gains total * le nb de gagnant dans la catégorie
stats.tbA1.Text = (taux(0) / 100) * gains
stats.tbA2.Text = (taux(1) / 100) * gains
stats.tbA3.Text = (taux(2) / 100) * gains
stats.tbA4.Text = (taux(3) / 100) * gains
stats.tbA5.Text = (taux(4) / 100) * gains
stats.tbA6.Text = (taux(5) / 100) * gains
'Calcul des pertes de la LOTO
Dim pertes As Integer = calcul(gains)
'Calcul du profit NET
stats.tbPertes.Text = pertes.ToString()
stats.tbNet.Text = Integer.Parse(stats.tbGains.Text) - pertes
'Fin de l'exécution et affichage de l'intervale dans la fenetre STATS
tsF = DateTime.Now.Subtract(tsS)
historique.tbTime.Text = tsF.Seconds & "." & tsF.Milliseconds
End Sub
End Class
in my Form2 behind .. there is only the pageLoad but in the aspx there is textbox numG1 to numG5
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Form2.aspx.vb" Inherits="Loto6_49_ASP.Form2" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Résultats</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="numG1" runat="server" Width="42px"></asp:TextBox>
<asp:TextBox ID="numG2" runat="server" Width="42px"></asp:TextBox>
<asp:TextBox ID="numG3" runat="server" Width="42px"></asp:TextBox>
<asp:TextBox ID="numG4" runat="server" Width="42px"></asp:TextBox>
<asp:TextBox ID="numG5" runat="server" Width="42px"></asp:TextBox>
<asp:TextBox ID="numG6" runat="server" Width="42px"></asp:TextBox>
</div>
</form>
</body>
</html>
thanks
If you submit the form, from "Form2.aspx" to "Default.aspx" than you have it in the request ("Get" or "POST").
If not, you can write public property for each input you want to be editable from outside the page or pass the values by session, querystring, cache etc...