Home > DeveloperSection > Forums > Keeping values on form after submition
Jayden Bell
Jayden Bell

Total Post:110

Posted on    August-27-2014 1:56 AM


 1 Reply(s)
 823  View(s)
Rate this:

I'm trying to keep the entered data in the form after submitting by using "value=..."

I'm getting a compilation error on the following code:

<form id="myform">

           <input id="hour" type="text" name="hour" value="<%=hour%>" style="width:30px; text-align:center;" /> :

           <input id="minute" type="text" name="minute" value="<%=minute%>" style="width:30px; text-align:center;" />


           <input type="submit" value="Validate!" />


the error is : Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'hour' does not exist in the current context

any solution? thanks a lot in advance

Sumit Kesarwani

Total Post:378

Posted on    August-27-2014 11:17 PM

Hi jayden, 

Action for submit must have parameter which have name like name of control on view or a model have property like name of control.

public ActionResult acTest(string hour, string minute)

{ ... }


public ActionResult acTest(iTime md)

{ ... }

public class iTime


   public string hour{get;set;}

   public string minute{get;set;}


Don't want to miss updates? Please click the below button!

Follow MindStick