How can i store data from a form created in mvc razor view without a model class and entity framework , I have wrote a simple method but as in razor view i have
@Html.TextBox("txtPrice", null, new { @class = "form-control valid", @data_val = "true", @data_val_required = "Property Price is required" })
How to get this textbox value in my c# code either i have to use Query String or what else is the technique i am good with web forms and i web forms we have runat="Server" attribute to access the text box but in razor i do not know how to achieve this.
MayankPosted Dec 22, 2016, 5:43 AM
public ActionResult Index(string txtPrice)
{
return View();
}
Manas MohapatraPosted Dec 19, 2016, 8:36 AM
Mangesh GPosted Dec 19, 2016, 8:13 AM
public ActionResult Create(FormCollection collection)
{
try
{
if (collection != null)
{
string userName = collection["txtdetails"].ToString();
}
// TODO: Add insert logic here
return View();
}
catch(Exception ex)
{
return View();
}
}
ViewBag.Title = "Create";
}
Create
@using (Html.BeginForm("Create", "Sample"))
{
@Html.TextBox("txtid","111");
}
Mark TaborPosted Dec 19, 2016, 5:33 AM
Salman BegPosted Dec 19, 2016, 5:24 AM
Mark TaborPosted Dec 19, 2016, 5:21 AM
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.Requested URL: /Property/SaveRecords
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET
Mark TaborPosted Dec 19, 2016, 2:53 AM
Mangesh GPosted Dec 18, 2016, 5:00 PM
Manas MohapatraPosted Dec 18, 2016, 2:02 PM
Mark TaborPosted Dec 18, 2016, 11:38 AM
Manas MohapatraPosted Dec 18, 2016, 9:32 AM
Mark TaborPosted Dec 18, 2016, 6:44 AM
Mark TaborPosted Dec 18, 2016, 6:09 AM
Salman BegPosted Dec 18, 2016, 5:51 AM