In this example I will show you how to pass string to view mvc in application. The appropriate way to you must cast in to an object and return as view. In view model you must define the object type and write the string in required place.
Step 1: Right click on the "Controllers" folder and add "Home" controller. Copy and paste the following code.
public class HomeController : Controller
public ActionResult Index()
string mystring = "this is a samplestring";
Step 2: Right click on the "Index" action method in the "HomeController" and add "Index" view. Copy and paste the following code.
ViewBag.Title = "passing string to view mvc";
<h2 style="color: orange">passing string to view mvc</h2>
<div style="color: blue">
Post your comments / questions
- How to check PAN-Aadhaar is Linked or NOT?
- How to customize pagination for django admin?
- How to fix HAXM is not installed |in Android Studio
- How to fix CMOS Checksum Error in Computer or Laptop | SOLVED
- Reactivating windows after a Hardware change on PC or Laptop
- FIXED: Windows reported that the hardware of your device has changed. Error code :0xc004F211
- "redirect" is not defined pylance("reportUndefinedVariable)
- This action cannot be completed because the file is open in SQL Server(SQLEXPRESS) - FIXED