I have an asp.net webform website that stores data in a session, and the entries entered on pg1 and pg2 are displayed on the third page.
On the first page, the first flags are preselected by default, but if the user selects / deselects the flag when the user is on the second page, the back button appears, but when it is pressed, I donβt know how to re-display the flags selected / not selected, since only the default value is checked.
I am new to using asp and storage of the session, so I can do something completely wrong, so please let me know if I am, but also help me to solve my situation, and not just vote for a message without explanation.
Anyway, my code is:
HTML
<div class="form-group"> <div class="col-xs-offset-0 col-sm-offset-4 col-sm-3">All services</div> <div class="col-sm-1"> <asp:CheckBox ID="Step02AllServices" runat="server" Checked="True" /> </div> </div> <div class="form-group"> <div class="col-xs-offset-0 col-sm-offset-4 col-sm-3">Site content uploading only</div> <div class="col-sm-1"> <asp:CheckBox ID="Step02ContentUploading" runat="server" /> </div> </div> <div class="form-group"> <div class="col-xs-offset-0 col-sm-offset-4 col-sm-3">Site content & layout checking</div> <div class="col-sm-1"> <asp:CheckBox ID="Step02ContentLayoutChecking" runat="server" Enabled="False" /> </div> </div>
Code for
protected void Step02SubmitButton_Click(object sender, EventArgs e) { Session["Step02AllServices"] = Step02AllServices.Checked; Session["Step02ContentUploading"] = Step02ContentUploading.Checked; Session["Step02ContentLayoutChecking"] = Step02ContentLayoutChecking.Checked; Response.Redirect("/Quotation/pg3.aspx"); }
I know this should be in my Page_Load , just not sure how to do this.
Below is what I have for the switches and test fields on another page
if (txtData2.Text == string.Empty && Session["pg2"] != null) { txtData2.Text = Session["pg2"].ToString(); if (Session["pg2Yes"].ToString() == "Yes") { pg2Yes.Checked = Session["pg2Yes"].Equals("Yes"); } if (Session["pg2No"].ToString() == "No") { pg2No.Checked = Session["pg2No"].Equals("No"); } }
source share