Posts

mvc pattern and asp.net mvc

MVC Pattern MVC stands for Model View Controller, it is a software development pattern that separates development concerns meaning all team members can independently work on his own. View: View contain s uiu your html tag which were rendered to browser. Model: Model is where all your business ASP.NET and MVC Framework

OptimisticVerificationException (Row not found: GenericOID@) in Artificial types.

possible cause of generating this problem. if you have two tables having parent child relationship e.g Table1: Student (studentId, name) Table2: Courses (courseId, name, studentId) in a scenario where you want operator to open student record in edit mode i.e showing his name + his enrolled course suppose initially two courses were enrolled but now operator wants to enroll 5 more courses, which will make it 7 courses all together. upon update you are following strategy as first remove all previous courses

multiple ways to call a partial view in asp.net mvc 5

there are scenarios where you want to minimize redundancy and fasten up productivity, hence partial views play role over here. 1st Approach suppose you are creating a user mgt application where you'll first add user with four input fields, then will show them in index page, if operator want to edit any user record, that record will get displayed in edit mode (same four fields) then upon update record gets saved in db. in this scenario either you have to create two different views create and update containing same fields OR you just make a template / partial view and call it in both views resulting in mitigating redundancy, increasing productivity, also if you want to make some changes, you dont need to update both views i.e (create / update) you'll only need to update one partial view. create.cshtml @model Model.User Html.BeginForm() { @RenderPartial() } update.cshtml partialuser.cshtml 2nd Approach what I see in your controller is a mix of methods. I ...

how to reset your visual studio settings

if your vs (any version) start hanging out / or showing error like 'unable to copy .exe from obj to bin' then it means you need to reset the developer environment settings For visual studio 2010, devenv was in: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE - run command line as administrator - goto specified path or as per your installation directory - write command devenv /ResetSettings

jquery each()

What is jQuery .each() jQuery’s each() function is used to loop through each element of the target jQuery object. In case you’re not really experienced in jQuery, I remind you that a jQuery object is an object that contains one or more DOM elements, and exposes all jQuery functions. It’s very useful for multi-element DOM manipulation, looping arbitrary arrays, and object properties. In addition to this function, jQuery provides a helper function with the same name that can be called without having previously selected or created DOM elements. Let’s find out more in the next sections. jQuery’s .each() Syntax Let’s see the different modes in action. The following example selects every div on the web page and outputs the index and the ID of each of them. A possible output is: “div0:header”, “div1:body”, “div2:footer”. This version uses jQuery’s each() function as opposed to the utility function. // DOM ELEMENTS $ ( 'div' ) . each ( function ( index , va...

communication between view and controller using ajax request

there are multiple ways of send a request to controller and returning data to populate dropdown or grid etc 1. send ajax request > return string array > parse to json > iterate through result SERVER SIDE / CONTROLLER   public string Get(string argSelectedValue) {      List resultList = new List();      SelectListItem selListItem = new SelectListItem() { Value = "null", Text = "Select One" };      resultList.Add(selListItem);      JavaScriptSerializer js = new JavaScriptSerializer(); return js.Serialize(new SelectList(resultList, "Value", "Text")); }   CLIENT SIDE / AJAX REQUEST  $.ajax({ url: "/Lookup/Get", type: 'POST', data: { argSelectedValue: FromType }, success: function (response) { var listItems = ""; var json = $.parseJSON(response); for (var i = 0; i < response.length; i++) { listItems += " " + ...

String or binary data would be truncated

While inserting row in SQL Server, whenever you encounter such error then you need to re-verify whether or not you are exceeding any column value for example in your sql table you have defined length of other_name as char(12) create table users ( code integer identity(1,1) primary key, username varchar(32) not null unique, other_number char(12) not null ) and if your insert statement is as follows insert into users (username,other_number) values('admin','1234567890123'); only then this error will come i.e  String or binary data would be truncated which means you are exceeding length check of column named other_name  therefore reducing it will insert row successfully like below. insert into users (username,other_number) values('admin',' 123456789012 ');