How to send data from one ASP.NET page to another
Hi all,
I am working as a developer in one company and need information about how to send data from one ASP.NET page to another. Since we cannot use ASP.NET Web Controls (System.Web.UI.WebControls) in such a scenario which only allow posting back of data to the same page. Please suggest. Thanks in advance.
Re: How to send data from one ASP.NET page to another
You can use Property Procedure and Context to transfer web form data to another page Read the program given below:
Code:
<%@ Page Language="VB" ClassName="SenderClass123" %>
<script runat="server">
' Readonly property for name
Public ReadOnly Property Name() As String
Get
Return USerName123.Text
End Get
End Property
'Readonly Property for phone
Public ReadOnly Property Phone() As String
Get
Return UserPhone123.Text
End Get
End Property
'Event to transfer page control to Result.aspx
Sub Page_Transfer(sender As Object, e As EventArgs)
Server.Transfer("Result123.aspx")
End sub
</script>
How to send data from one ASP.NET page to another
You can also use this method that uses Context object to retrieve the data. It's simple and straight forward, you don't need to create property procedures at all.
Code:
<!-- UserForm000.aspx -->
<%@ Page Language="VB" %>
<script runat="server">
'Event to transfer page control to Result123.aspx
Sub Page_Transfer (sender123 as Object, e as EventArgs)
'Storing in Context
Context.Items("UseNam") = UserNam.text
Context.Items("UsePhon") = UserPhon.text
Server.Transfer("Result123.aspx")
End sub
</script>
Re: How to send data from one ASP.NET page to another
You need to add another code to above procesure.
Code:
<html>
<head>
</head>
<body>
<form runat="server">
User Name:
<asp:TextBox ID="UseNam" runat="server" />
Phone:
<asp:TextBox ID="UsePhon" runat="server" /><br>
<asp:Button Text="Submit" OnClick="Page_Transfer"
runat="server" />
</form>
</body>
</html>
How to send data from one ASP.NET page to another
In . net, The CompareValidator and RangeValidator both compare values to literals or extra user-entered data. The two controls inescapably hold some common functionality and therefore are resultant from the BaseCompareValidator class. The BaseCompareValidator just offers us one property in addition to those offered by the BaseValidator class. Its type class permits strings of exact formats to be compared exactly. Check that and reply.