I have a Web Application in Asp.Net WebForm.
On a web page there are two tabs Student1 and Student2 and both the tab contain the same form which has two TextBox fields FirstName and LastName.
Now let us suppose, I am currently on the Student1 tab and the value of FirstName and LastName is FirstOne and LastOne respectively. Now, I click on Student2 Tab, then the Student1 form is automatically submitted and the value of FirstName and LastName
form Student1 Tab is saving in a session.
var student1DataCollection= HttpContext.Current.Request.Form; //DataTye is NameValueCollection
Session["Student1"] = student1DataCollection;
So, Whenever I come back to Student1 the same value of the FirstName and SecondName is displayed in the form. This works similarly for Student2 Tab.
But now my requirement is to save the value of the form manually.
((TextBox)Page.Master.FindControl("ContentPlaceHolder1").FindControl("FirstName")).Text = "TestFirstName"
((TextBox)Page.Master.FindControl("ContentPlaceHolder1").FindControl("LastName")).Text =
"TestLastName"
As we see I have assigned values for FirstName and LastName manually. Now I need to save this value of FirstName and LastName in Session["Student1"] in the form of NameValueCollection so that whenever I go to Student1 Tab. The value is displayed
How Can I convert this value to NameValueCollection?