Venkatesh Pettem

Venkatesh Pettem

  • NA
  • 343
  • 9.6k

How to assign value to input field ?

Mar 17 2020 2:07 AM
Hello,
 
Im working on html content to disply data in mvc view binding data from model class, my requirement is to set values to input fields to html content from c#.
 
i want final content should come up with html content and values from model.
 
EXAMPLE:
  1. <form action="/action_page.php">  
  2. <label for="fname">First name:</label>  
  3. <input type="text" id="fname" name="fname"><br><br>  
  4. <label for="lname">Last name:</label>  
  5. <input type="text" id="lname" name="lname"><br><br>  
  6. <input type="submit" value="Submit">  
  7. </form>  
This is my html content which is coming from text file. i've data in my model, i.e,
  1. public class EmployeeModel  
  2. {  
  3. public string fname { getset; } = "CSharp";  
  4. public string lname { getset; } = "Corner";  
  5. }  
In View :
 
@Html.Raw(ViewBag.htmlContent)

Answers (3)