Posts

Htc sensation XL mobile not working with windows 7 or above, along with Htc sync software

Problem: Htc sensation XL connectivity issue with windows 7 or above + Htc sensation XL device detection issue with Android Studio + Htc sensation XL connectivity issue with Htc sync software Solution: For all of the above mentioned issues, please see steps below for smooth & successful activity. Please make sure that 1. In Pc, Htc sync software version 3.2.26 or 3.3.63 is installed. 2. Ur device is connected to PC via usb cable. 3. In mobile, change connectivity options from 'charging' to 'htc sync' 4. In Pc, goto device manager and see for hardware changes in order to see whether device is detected by Pc or not yet, If yes you are good to go, if not follow below mentioned steps 5. Run htc sync in compatible mode by going to properties and changing OS to windows vista, then re-run Htc sync software and re-connect from mobile to see if it detects changes or not, if yes we are good to go but if not see below 6. In Pc, install htc usb drivers fro...

working with cache Context.Cache.ReleaseAll();

turn on hibernate in vista

Go to the command prompt icon in the Start menu under Accessories and right click the icon: click “Run as administrator”. Paste: “powercfg.exe /hibernate on” and hit Enter and also paste “powercfg -h on” and hit enter just to be safe. Open Control Panel and type in “Hibernate” in the Search.

post form data and bind with model : using jquery ajax in mvc

There are multiple ways of posting data from view to controller using jquery + ajax in mvc 1. post data by assigning parameters one by one and bind it with model manually 2. post data by serializing form and automatically binding with model 3. post data by assigning parameters one by one + making custom class and assigning data to its variables which are named similarly as that of model Method 1:     $.ajax({         url: "/Controller/SubmitAction",         type: "POST",         dataType: "text",         data: { name: _name, age: _age, id: _id },         success: function (response) {             alert("Success");         },         error: function () {             alert("Error");         }     }); public JsonResult Sub...

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 ');

icons not displaying properly in windows

Sometimes due to few installations, you feel like the folder / file icons are not being displayed the way it should be, i am sharing you the way of solving such problem. Here's a slightly quicker version of the instructions. 1. Press Ctrl-Shift-Escape to get the task manager. 2. In the Processes tab, click on explorer.exe and click End Process. You'll get a confirmation dialog. Click "End Process" to confirm. 3. From the File menu (still in the task manager), choose New Task (Run...). 4. Copy/paste/enter the following command in the run box: Code: cmd /c del %userprofile%\AppData\Local\IconCache.db /a 5. Open the Run box again with File --> New Task (Run...). This time, enter this command: Code: explorer.exe 6. All should be okay now. Open the Start Menu and confirm that your icons are fixed now.

storing byte array as column value in datatable using c#

This post covers following objective 1. How to declare and define datatable 2. Add columns at runtime 3. Add column to store byte array (image/file etc) //YOUR PHOTOGRAPH HERE MemoryStream ms = new MemoryStream(); argPhotograph.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); //DECLARING DATATABLE DataTable dt = new DataTable ();   dt . Columns . Add ( "ID" ); dt . Columns . Add ( "Name" ); dt . Columns . Add ( "CreatedOn" , typeof ( DateTime )); dt . Columns . Add ( "Photograph" , typeof ( byte []));   //METHOD 1: ADDING DATA DataRow row = null; row = dt.NewRow(); row[ "ID"] = 1; row[ "Name"] = "Usman"; row[ "CreatedOn"] = DateTime.Now; row[ "Photograph"] = argPhotograph.ToArray(); dt.Rows.Add(row);  //METHOD 2: ADDING DATA dt.Row.Add( 1, "Usman", DateTime.Now, argPhotograph.ToArray());

validate uploaded image wrt size, format in asp.net mvc5

[HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(Model argModel, HttpPostedFileBase file) {    string msg = Utilities.IsImageValid(file);    if (!msg.Trim().Equals("ok"))    {       ModelState.AddModelError("", msg);    }    if (ModelState.IsValid)    {         //saving here         return View("Index");     }     return View("Create", argModel); } public class Utilities     {         public static string IsImageValid(object value)         {             var file = value as HttpPostedFileBase;             if (file == null)             {                 return "Please attach photograph.";             } ...

form authentication using custom principle in asp.net mvc

Here's how I do it. I decided to use IPrincipal instead of IIdentity because it means I don't have to implement both IIdentity and IPrincipal. Create the interface interface ICustomPrincipal : IPrincipal { int Id { get ; set ; } string FirstName { get ; set ; } string LastName { get ; set ; } } CustomPrincipal public class CustomPrincipal : ICustomPrincipal { public IIdentity Identity { get ; private set ; } public bool IsInRole ( string role ) { return false ; } public CustomPrincipal ( string email ) { this . Identity = new GenericIdentity ( email ); } public int Id { get ; set ; } public string FirstName { get ; set ; } public string LastName { get ; set ; } } CustomPrincipalSerializeModel - for serializing custom information into userdata field in FormsAuthenticationTicket object. public class CustomPrincipalSerializeModel { ...