相關文章:Bootstrap Modal immediately disappearing
剛好我就是這個原因,因為我是使用 asp.net mvc開發
不小心使用了 script.render載入了兩次 bootstrap.js,後來拿掉後就沒有這個問題了
2015年4月2日 星期四
2015年3月31日 星期二
開啟 bootstrap modal會造成首頁內容左移 (shit to left)
解決方式 Twitter Bootstrap modal pushes html content to the left
主要的作法就是在 css加上如下內容
主要的作法就是在 css加上如下內容
html {
overflow: hidden;
height: 100%;}
body {
overflow: auto;
height: 100%;}
/* unset bs3 setting */.modal-open {
overflow: auto;
}
2015年2月22日 星期日
ERP set default org for view
begin
MO_GLOBAL.SET_POLICY_CONTEXT('S',121);
end;
select
sys_context('multi_org2','current_org_id')
from
dual
MO_GLOBAL.SET_POLICY_CONTEXT('S',121);
end;
select
sys_context('multi_org2','current_org_id')
from
dual
遞迴~~~ 百元買百雞
從工作開始~~程式使用遞廻的寫法並不多,一是順展、逆展 BOM,另一個是前公司因為接了 Apple的產品,其 barcode 2D有特殊的編碼原則,所以也用遞迴產生,而這次是因為姪子在大陸復旦大學讀一年級,上了 C的課程,教授出了一個作業名叫百元買百雞,規則如下,公雞1隻3元,母雞1隻1元,小雞1元3隻,請問用一百元買一百隻雞的組合為何,請用程式表現出來,真不知道是大陸的學生程度太高,還是我們太笨,叫一年級的學生寫這個,當下聽到這個題目時,直覺應該是用遞迴的方式,只是不能馬上寫的出來,而且也不想丟臉,所以用力了想了一個下午就寫好了,但是用 C#寫出來的,有興趣的人也可以試試
2014年11月4日 星期二
asp.net MVC 多國語系設定
參考文件
ASP.NET MVC 讓 jQuery Validation Plugin 動態切換顯示訊息語系
ASP.NET MVC And Localization
ASP.NET Boilerplate Localization
ASP.NET MVC 你一定要知道怎麼創立HTML Helper
Attributes Tutorial
Localization in ASP.NET MVC 4 – Upgraded
asp.net mvc multilanguage urls/routing =>要客製一個 controller而且所有新建的controller都要繼承它
ASP.NET MVC Localization - Routing => controller不用繼承客制的 controller (目前我使用的)
目前我參考的這一個算是蠻好設定的而且有範例碼在 GitHub,自己也有學到新東西
比如 RouteCollectionExtensions,建立一個靜態的類別,在 RouteConfig就可以使用它的方法
public static class RouteCollectionExtensions,而在作語系切換時只要將 cookie locale的值設定為指定語系即可
ASP.NET MVC + ANGULARJS SPA + LOCALIZATION
ASP.NET MVC With AngularJS
如果有使用 angularjs 並且將網頁設定成 SPA方式的話,我使用的方式還要再作修改,要不然angularjs route碰到下列情況就會有問題
.when('/routeTwo/:donuts', { templateUrl: function(params) { return '/routesDemo/two?donuts=' + params.donuts; } })
public void ProcessRequest(HttpContext context)
{
NameValueCollection queryParameters = context.Request.QueryString;
string qTring = string.Empty;
if (queryParameters.Count > 0)
{
qTring = "?" + queryParameters.ToString();
}
context.Response.Redirect(this._newUrl+ qTring);
}
ASP.NET MVC With AngularJS
@Scripts.Render("~/bundles/angularjs") 要放在 angular.module使用之前
使用 controller的寫法
1.2
function HelloController($scope) {
$scope.greeting = { text: 'Hello' };
}
1.3
var myApp = angular.module('myApp', []);
myApp.controller('HelloController', ['$scope', function ($scope) {
$scope.greeting = { text: 'Hello' };
} ]);
or
function HelloController($scope) {
$scope.greeting = { text: 'Hello' };
}
// The $inject property of every controller (and pretty much every other type of object in Angular) needs to be a string array equal to the controllers arguments, only as strings
HelloController.$inject = ['$scope'];
var myApp = angular.module('myApp', []);
myApp.controller('HelloController', HelloController);
SPA 注意事項
1.要設定 SPA要先加入 angular-route.min.js
//AngularJS
bundles.Add(new ScriptBundle("~/bundles/angularjs").Include(
"~/Scripts/angular.min.js"
, "~/Scripts/angular-route.min.js"
));
2.設定連結
a href="/#/routeOne"
如果 default網頁是 Index.cshtml,可以寫成如上的連結,但如果不是,比如有一個網頁叫 SPATest.cshtml放在 Home目錄底下的話,連結修改如下:
a href="/Home/SPATest/#/routeOne"
3.加上一個 <div ng-view></div>在你的 Index.cshtml (SPA的首頁)上
4.設定 angulasjs route,可儲存在 javascript檔
//routing for angularjs
var configFunction = function ($routeProvider) {
$routeProvider.
when('/routeOne', {
templateUrl: '/RoutesDemo/one'
})
.when('/routeTwo', {
templateUrl: '/RoutesDemo/two'
})
.when('/routeThree', {
templateUrl: '/RoutesDemo/three'
});
}
configFunction.$inject = ['$routeProvider'];
myApp.config(configFunction);
5. 建立 contorller
public class RoutesDemoController : Controller
{
//
// GET: /RouttesDemo/
public ActionResult One()
{
ViewBag.test = 1;
return PartialView("SPAPartialTest");
}
public ActionResult Two(int donuts = 1)
{
ViewBag.Donuts = donuts;
ViewBag.test = 1;
return PartialView("Two");
}
public ActionResult Three()
{
ViewBag.test = 3;
return PartialView("SPAPartialTest");
}
}
6.建立 partialview
Hands On Lab: Build a Single Page Application (SPA) with ASP.NET Web API and Angular.js
Using AngularJs, ASP.NET MVC, Web API and EntityFramework to build NLayered Single Page Web Applications
【AngularJs + ASP.NET MVC】使用AntularJs快速建立ASP.NET MVC SPA網站
Getting started with AngularJS and ASP.NET MVC - Part One
Getting started with AngularJS and ASP.NET MVC - Part Two
AngularJS 開發 ASP.NET MVC
What's the difference between “return View()” and “return PartialView()”
使用 controller的寫法
1.2
function HelloController($scope) {
$scope.greeting = { text: 'Hello' };
}
1.3
var myApp = angular.module('myApp', []);
myApp.controller('HelloController', ['$scope', function ($scope) {
$scope.greeting = { text: 'Hello' };
} ]);
or
function HelloController($scope) {
$scope.greeting = { text: 'Hello' };
}
// The $inject property of every controller (and pretty much every other type of object in Angular) needs to be a string array equal to the controllers arguments, only as strings
HelloController.$inject = ['$scope'];
var myApp = angular.module('myApp', []);
myApp.controller('HelloController', HelloController);
SPA 注意事項
1.要設定 SPA要先加入 angular-route.min.js
//AngularJS
bundles.Add(new ScriptBundle("~/bundles/angularjs").Include(
"~/Scripts/angular.min.js"
, "~/Scripts/angular-route.min.js"
));
2.設定連結
a href="/#/routeOne"
如果 default網頁是 Index.cshtml,可以寫成如上的連結,但如果不是,比如有一個網頁叫 SPATest.cshtml放在 Home目錄底下的話,連結修改如下:
a href="/Home/SPATest/#/routeOne"
3.加上一個 <div ng-view></div>在你的 Index.cshtml (SPA的首頁)上
4.設定 angulasjs route,可儲存在 javascript檔
//routing for angularjs
var configFunction = function ($routeProvider) {
$routeProvider.
when('/routeOne', {
templateUrl: '/RoutesDemo/one'
})
.when('/routeTwo', {
templateUrl: '/RoutesDemo/two'
})
.when('/routeThree', {
templateUrl: '/RoutesDemo/three'
});
}
configFunction.$inject = ['$routeProvider'];
myApp.config(configFunction);
5. 建立 contorller
public class RoutesDemoController : Controller
{
//
// GET: /RouttesDemo/
public ActionResult One()
{
ViewBag.test = 1;
return PartialView("SPAPartialTest");
}
public ActionResult Two(int donuts = 1)
{
ViewBag.Donuts = donuts;
ViewBag.test = 1;
return PartialView("Two");
}
public ActionResult Three()
{
ViewBag.test = 3;
return PartialView("SPAPartialTest");
}
}
6.建立 partialview
Hands On Lab: Build a Single Page Application (SPA) with ASP.NET Web API and Angular.js
Using AngularJs, ASP.NET MVC, Web API and EntityFramework to build NLayered Single Page Web Applications
【AngularJs + ASP.NET MVC】使用AntularJs快速建立ASP.NET MVC SPA網站
Getting started with AngularJS and ASP.NET MVC - Part One
Getting started with AngularJS and ASP.NET MVC - Part Two
AngularJS 開發 ASP.NET MVC
What's the difference between “return View()” and “return PartialView()”
訂閱:
文章 (Atom)