This is blog by the developer and for the developer.I am creating this blog for help the people to learn from basic to advance level concepts in technology world.
Test Post from Sagar Jaybhay
Get link
Facebook
X
Pinterest
Email
Other Apps
Test Post from Sagar Jaybhay https://sagarjaybhay.net
In this article we will understand How to delete data using Post request in Asp.Net MVC? and How to add Confirmation alert box on button click in Asp.Net MVC by Sagar Jaybhay . Always remember if you want to delete data from the database use Post request. Never use Get request for deleting resources on a database. Because if you have to get a call to delete data from the database and any hacker or some malicious user got your Get URL then he can delete your data. Also, google try to index your page as an SEO point view so if you issue get request then it’s not good practice to delete data using Get so always use Post request to delete data. In our application see below image we use action link to delete Employee from a database but this will issue a get request to avoid this we need to use the button for post-call and this we need to use Form control in our application so we rap our application inside form and issues a Post call for delete. To create button control here code is ...
In this article we will understand model binding updateModel tryupdateModel -mvc ASP.NET MVC By Sagar Jaybhay . But for this you need to read previous article where we start CRUD Operation in MVC . Model Binding [HttpPost] public ActionResult Create(string EmpName, string EmpSalary, string gender, string EmpEmail, string EmpCity, int departmentid ) var employee = new Employee() EmpName= EmpName, EmpSalary=Convert.ToDouble(EmpSalary), EmpCity= EmpCity, EmpEmail= EmpEmail, EmpGender=gender, DepartmentID=departmentid ; new BusinessLogic.Business().CreateEmployee(employee); return RedirectToAction("DisplayCompleteEmployee"); In this above method, we use the method parameter and when we click on Create button this method is called. Also, we can use FormCollection in this which required the key to access data and we get this key from formcollectionobject.allkeys get all keys. But how the form textboxes are bind correct data to parameters in that method is by using...
In this article we will understand What is the purpose of Html helpers in MVC ? and How to generate DropDownList using Html helpers in Asp.net MVC by Sagar Jaybhay . Html helpers What is an Html Helper? Html helper is a method that is used to render HTML content in a view. Html helpers are implemented using an extension method. If you want to create an input text box with id=email and name is email <input type=text id=email name=email value=’’/> This is all Html we need to write by using the helper method it becomes so easy @Html.TextBox(‘email’) It will generate textbox control whose name is email. If we want to assign the value of the textbox with some initial value then use below method. @Html.TextBox(‘email’,’sagar@gmail.com’) If I want to set an initial style for textbox we can achieve this by using below way. @Html.TextBox(‘email’,’sagar@gmail.com’,new style=’your style here’ , title=...
Comments
Post a Comment