ok
I test it again these are code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataLayerB;
using System.Data;
using System.Data.SqlClient;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.IO;
using System.Drawing;
[Serializable()]
public partial class دریافت_آدرس_گیرنده : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
LblPostS.Text = "4000";
LblPostP.Text = "6000";}
protected void LBsabt_Click(object sender, EventArgs e)
{
if (DdlCity.SelectedItem.Value != "0" && DdlCity.SelectedItem.Text == "تهران")
{
UserData user = new UserData
{
Name = Txtname.Text,
State = DdlState.SelectedItem.Text.Trim(),
City = DdlCity.SelectedItem.Text,
Zone = Ddlzone.SelectedItem.Text,
Mobile = TxtMob.Text,
Tell = txttell.Text,
Address = Txtaddu.Text,
PostCode = TxtcodeU.Text,
Email = TxtEmail.Text,
Price = Rbsefareshi.Checked ? LblPostS.Text : LblPostP.Text,
Sefareshi = Rbpishtaz.Checked ? "پست پیشتاز" : lblfree.Text,
SefareshiP = Rbpishtaz.Checked ? "پیشتاز" : lblfreeP.Text,
};
Session["UserData"] = user;
}
else {
if (DdlState.SelectedItem.Value != "0" && DdlState.SelectedItem.Text != "تهران")
{
UserData user = new UserData
{
Name = Txtname.Text,
State = DdlState.SelectedItem.Text.Trim(),
City = "-",
Zone = "-",
Mobile = TxtMob.Text,
Tell = txttell.Text,
Address = Txtaddu.Text,
PostCode = TxtcodeU.Text,
Email = TxtEmail.Text,
Price = Rbsefareshi.Checked ? LblPostS.Text : LblPostP.Text,
Sefareshi = Rbpishtaz.Checked ? "پست پیشتاز" : lblfree.Text,
SefareshiP = Rbpishtaz.Checked ? "پیشتاز" : lblfreeP.Text,
};
Session["UserData"] = user;
}
else {
UserData user = new UserData
{
Name = Txtname.Text,
State = DdlState.SelectedItem.Text.Trim(),
City = DdlCity.SelectedItem.Text,
Zone = "-",
Mobile = TxtMob.Text,
Tell = txttell.Text,
Address = Txtaddu.Text,
PostCode = TxtcodeU.Text,
Email = TxtEmail.Text,
Price = Rbsefareshi.Checked ? LblPostS.Text : LblPostP.Text,
Sefareshi = Rbpishtaz.Checked ? "پست پیشتاز" : lblfree.Text,
SefareshiP = Rbpishtaz.Checked ? "پیشتاز" : lblfreeP.Text,
};
Session["UserData"] = user;
}
}
Response.Redirect("پرداخت-مبلغ-خرید.aspx");
}
}
but again this error happen:
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.