แสดงบทความที่มีป้ายกำกับ MVC แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ MVC แสดงบทความทั้งหมด

วันอาทิตย์ที่ 31 พฤษภาคม พ.ศ. 2558

MVC Code First Command

enable-migrations

add-migration

update-database  

วันพฤหัสบดีที่ 26 มิถุนายน พ.ศ. 2557

A circular reference was detected while serializing an object of type 'System.Data.Entity.DynamicProxies.xxx'

This happened when i need to use auto complete to get Object list by Entity.
Yep i support i use Lazy loading so
before call and return code must config for not Lazy loading like


db.Configuration.ProxyCreationEnabled = false;

วันจันทร์ที่ 10 มิถุนายน พ.ศ. 2556

EPPlus Format cell as text.

I need to type like 08x-xxx-xxxx but can't because General format will convert text to number and will be 8x-xxx-xxxx that not fit requirement.

fix this by
worksheet.Cells["A1"].Style.NumberFormat.Format="@"

this command will convert cell to Text Style.

วันศุกร์ที่ 5 ตุลาคม พ.ศ. 2555

Generate url string in Codebehind in MVC3

Yes I try "UrlHelper.GenerateUrl" before and it suck.
so came in to this solution
I use with static  Code so it came up here with reference to

using System.Web.Mvc;
using System.Web.Routing;

and declare this


HttpContextWrapper httpContextWrapper = new HttpContextWrapper( System.Web.HttpContext.Current );
UrlHelper urlHelper = new UrlHelper( new RequestContext( httpContextWrapper, RouteTable.Routes.GetRouteData( httpContextWrapper ) ) );

and use like this


string url = urlHelper.Action( "Action", "Controller name", new { id = 1 } );
sb.Append( String.Format( "{1}", url, "Link Text" ) );

more information can see solution in
http://stackoverflow.com/questions/2031995/call-urlhelper-in-models-in-asp-net-mvc



วันจันทร์ที่ 27 สิงหาคม พ.ศ. 2555

MVC Configuration Error after Upload to IIS Server

Parser Error Message : Could not load file or assembly 'System.Web.Helpers, Version=1.0.0.0, Culture...'
This mean your IIS server may not support MVC dlls. so to fix this has 2 ways
Deploy MVC Dependencies with Visual Studio or Install MVC in Server for support MVC Project.

วันพฤหัสบดีที่ 23 กุมภาพันธ์ พ.ศ. 2555

Sammple MVC Custom Dropdown list.


<select id="categories" name="categories">
    @foreach (var item in selectList) {
        <option @if (item.Selected) { selected="selected"text>} value="@item.Value">@item.Textoption>
    }
select>

วันพุธที่ 16 พฤศจิกายน พ.ศ. 2554

Linq and about OrderBy

Linq has OrderBy and OrderByDescending when need multiple order use ThenBy or ThenByDescending

วันพุธที่ 9 มิถุนายน พ.ศ. 2553

How to set default route to Area

Is simple by open your {AreaName}AreaRegistration.cs

and use (Example I add Install Area and need it default page.)

public override void RegisterArea( AreaRegistrationContext context )
{
//context.MapRoute(
// "Install_default",
// "Install/{controller}/{action}/{id}",
// new { action = "Index", id = UrlParameter.Optional }
//);

context.MapRoute(
"Install_default",
"{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional, controller = "Install" },
new { controller = "Install" }
);
}

No need to change other.

ref url is http://stackoverflow.com/questions/2140208/how-to-set-a-default-route-to-an-area-in-mvc