Hi muhammad12,
You need to make use of Session to send the details.
First create a class having required properties.
Then in the Print Button click, create an object of the class and set the properties from the controls value.
Finally, set the class object in Session and access in other page.
Refer below exampple.
Property Class
C#
public class Dispatch
{
public string Name { get; set; }
public string PO { get; set; }
public string ItemName { get; set; }
public string Quantity { get; set; }
public string ConfirmTo { get; set; }
public string Notes { get; set; }
public string From { get; set; }
}
VB.Net
Public Class Dispatch
Public Property Name As String
Public Property PO As String
Public Property ItemName As String
Public Property Quantity As String
Public Property ConfirmTo As String
Public Property Notes As String
Public Property From As String
End Class
HTML
Dispatched
<div class="container">
<div class="form-row">
<div class="form-group">
<label for="DropDownList1">To:</label>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="">Please Select</asp:ListItem>
<asp:ListItem>muhammad</asp:ListItem>
<asp:ListItem>Abdullah</asp:ListItem>
</asp:DropDownList>
</div>
<div class="form-group">
<label for="TextBox1">PO#:</label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="TextBox2">Item Name:</label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<label for="TextBox3">Quantity:</label>
<asp:TextBox ID="TextBox3" runat="server" TextMode="Number"></asp:TextBox>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="TextBox4">Confirm To:</label>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="TextArea1">Notes:</label>
<textarea id="TextArea1" runat="server" rows="4"></textarea>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="DropDownList2">From:</label>
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem Value="">Please Select</asp:ListItem>
<asp:ListItem>abnc</asp:ListItem>
<asp:ListItem>xyz</asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="button-container">
<asp:Button ID="Button1" runat="server" Text="Print" OnClick="OnPrint" CssClass="btn-print" />
</div>
</div>
Print
Name: <asp:Label ID="lblName" runat="server" /><br />
#PO: <asp:Label ID="lblPO" runat="server" /><br />
Item: <asp:Label ID="lblItemName" runat="server" /><br />
Quantity: <asp:Label ID="lblQuantity" runat="server" /><br />
Confirm To:<asp:Label ID="lblConfirmTo" runat="server" /><br />
Notes: <asp:Label ID="lblNotes" runat="server" /><br />
From: <asp:Label ID="lblFrom" runat="server" />
Code
Dispatched
C#
protected void OnPrint(object sender, EventArgs e)
{
Dispatch dispatch = new Dispatch();
dispatch.Name = DropDownList1.SelectedItem.Text;
dispatch.PO = TextBox1.Text;
dispatch.ItemName = TextBox2.Text;
dispatch.Quantity = TextBox3.Text;
dispatch.ConfirmTo = TextBox4.Text;
dispatch.Notes = TextArea1.InnerText;
dispatch.From = DropDownList2.SelectedItem.Text;
Session["Dispatch"] = dispatch;
Response.Redirect("~/Print.aspx");
}
VB.Net
Protected Sub OnPrint(ByVal sender As Object, ByVal e As EventArgs)
Dim dispatch As Dispatch = New Dispatch()
dispatch.Name = DropDownList1.SelectedItem.Text
dispatch.PO = TextBox1.Text
dispatch.ItemName = TextBox2.Text
dispatch.Quantity = TextBox3.Text
dispatch.ConfirmTo = TextBox4.Text
dispatch.Notes = TextArea1.InnerText
dispatch.From = DropDownList2.SelectedItem.Text
Session("Dispatch") = dispatch
Response.Redirect("~/Print.aspx")
End Sub
Print
C#
protected void Page_Load(object sender, EventArgs e)
{
Dispatch dispatch = (Dispatch)Session["Dispatch"];
lblName.Text = dispatch.Name;
lblPO.Text = dispatch.PO;
lblItemName.Text = dispatch.ItemName;
lblQuantity.Text = dispatch.Quantity;
lblConfirmTo.Text = dispatch.ConfirmTo;
lblNotes.Text = dispatch.Notes;
lblFrom.Text = dispatch.From;
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim dispatch As Dispatch = CType(Session("Dispatch"), Dispatch)
lblName.Text = dispatch.Name
lblPO.Text = dispatch.PO
lblItemName.Text = dispatch.ItemName
lblQuantity.Text = dispatch.Quantity
lblConfirmTo.Text = dispatch.ConfirmTo
lblNotes.Text = dispatch.Notes
lblFrom.Text = dispatch.From
End Sub
Screenshots
Dispatched
Print