Hi nedash,
The class UserData's object which you are using to save in session need to be serialize and page class too need to be serialize from where you trying to save the data to session so kindly make your UserData Class and Current Class Serialize for eg.
[Serializable()]
public class UserData //your class.
{
//Your Data.
}
[Serializable()]
public partial class YourCurrentPageClass
{
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 {
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");
}
}