0

I have textboxes when the user write information in those text box and then press submit button the data on that text boxes are loose ? is there any solution ? why this this data not persist after submitt like in ASP net Web form here is the code :

the View:

<% Html.BeginForm(); %>
    <!-- Form content goes here --> 
   Product Name: <%=Html.TextBox("textField") %>
   QTY: <%=Html.TextBox("textField") %>
   <input type="submit" value="Validate in Store" >
<% Html.EndForm(); %>

So when the user inser Product Name & QTY and then press on "Validate in store" the data in View is loose.

Regards

Nahed

JPNN
  • 383
  • 1
  • 7
  • 23

1 Answers1

0

I could go on and on how HTTP is stateless or that this is the really the right way to go about it.

But to answer your question why does data gets loose as you put it, it is because HTTP is stateless (I know I should stop repeating myself).State is not preserved from one request to another.Please read it about here.

To answer your second question, yes you can bind your view to a model so any changes to the model will automatically be picked up by the view.

To answer your third and final question, ASP.NET webforms uses ViewState to preserve data in the view.Read more about it here.

This leads to unnecessary page bloats and abstraction to such an extent that some developers actually think that state must automatically be maintained by HTTP. It takes getting used to but you can start reading on some MVC basics here.

I hope I have answered your questions.

Community
  • 1
  • 1
Ashutosh
  • 1,000
  • 15
  • 39