RouteData routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current));
if (routeData == null) return;
string action= routeData.GetRequiredString("action");
Friday, July 5, 2013
How to get RouteData in Application_BeginRequest or Application_EndRequest
Wednesday, July 3, 2013
How to make a CodeSnippet in Visual Studio for i18n?
If use i18n for ASP.NET MVC, need to add a lot of surroundings for strings.
A CodeSnippet could help a little bit:
In VS, Tools menu, click Code Snippets Manager. then import following xml file:
A CodeSnippet could help a little bit:
In VS, Tools menu, click Code Snippets Manager. then import following xml file:
i18n i18n Code snippet for @_ Microsoft Corporation Expansion SurroundsWith expression Exception type SimpleTypeName(global::System.Exception)
Friday, June 28, 2013
How to solve JavaScript error: Unable to get value of the property '': object is null or undefined?
There are normally two reasons to cause this problem:
1. Lost reference of needed JavaScript library.
2. The reference JavaScript library is not loaded when your script run.
1. Lost reference of needed JavaScript library.
2. The reference JavaScript library is not loaded when your script run.
Thursday, June 27, 2013
How to set and get selected value in dropdown list by jQuery
Set selected value:
var selectstring = 'select option[value="' + selectedValue + '"]';
$(selectstring).attr('selected', true);
Get selected value:
$("#dropdownlistId").change(function () {
alert($("#dropdownlistId").val());
});
var selectstring = 'select option[value="' + selectedValue + '"]';
$(selectstring).attr('selected', true);
Get selected value:
$("#dropdownlistId").change(function () {
alert($("#dropdownlistId").val());
});
Wednesday, June 26, 2013
Javascript Cookie helper
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
Reference:
http://www.quirksmode.org/js/cookies.html
Subscribe to:
Posts (Atom)