http://blog.rtwilson.com/want-to-write-some-code-get-away-from-your-computer/
Being away from the computer forces you to run through all of the thoughts in your head – which tends to take longer than getting a computer to compile and run your code (for small code bases at least…). So you don’t tend to make tiny changes and re-run things, you tend to actually think about what the code is doing. Until I did this on the train the other day, I hadn’t actually run a piece of code on paper (that is, written down columns for each of the variables and worked out what each value will be at each stage in the program) since my Computing A-Level exam!
Thursday, March 31, 2011
ASP Classic Compiler is an open source project now, Apache License
This project hosts examples, tests and discussions of ASP Classic Compiler. ASP Classic Compiler is based on a VBScript compiler that compiles ASP pages into a .NET executable so that they can run inside the ASP.NET environment.
http://aspclassiccompiler.codeplex.com/license
http://aspclassiccompiler.codeplex.com/license
Code example for developing Mobile web app by ASP.NET MVC 3 and jQuery Mobile
Mobile enabled web apps with ASP.NET MVC 3 and jQuery Mobile
Making this application for mobile devices. A single web site will be used for both mobile browsers and desktop browsers. If users are accessing the web app from mobile browsers, users will be redirect to mobile specific pages and will get normal pages if users are accessing from desktop browsers. In this demo app, the mobile specific pages are maintained in an ASP.NET MVC Area named Mobile and mobile users will be redirect to MVC Area Mobile
http://weblogs.asp.net/shijuvarghese/archive/2011/02/25/mobile-enabled-web-apps-with-asp-net-mvc-3-and-jquery-mobile.aspx
Making this application for mobile devices. A single web site will be used for both mobile browsers and desktop browsers. If users are accessing the web app from mobile browsers, users will be redirect to mobile specific pages and will get normal pages if users are accessing from desktop browsers. In this demo app, the mobile specific pages are maintained in an ASP.NET MVC Area named Mobile and mobile users will be redirect to MVC Area Mobile
http://weblogs.asp.net/shijuvarghese/archive/2011/02/25/mobile-enabled-web-apps-with-asp-net-mvc-3-and-jquery-mobile.aspx
Wednesday, March 30, 2011
Where can find ASP.NET Membership database script file?
In Windows .Net Framework folder:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallMembership.sql
C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallMembership.sql
Routing in ASP.NET WebForms
http://www.west-wind.com/weblog/posts/974489.aspx
protected void Application_Start(object sender, EventArgs e) { RegisterRoutes(RouteTable.Routes); } void RegisterRoutes(RouteCollection routes) { routes.MapPageRoute("StockQuote", "StockQuote/{symbol}", "StockQuote.aspx"); "); }public partial class StockQuote1 : System.Web.UI.Page
{ protected StockQuote Quote = null; protected void Page_Load(object sender, EventArgs e) { string symbol = RouteData.Values["symbol"] as string; } }
Tuesday, March 29, 2011
Ios, Android, WP7 - who cares
Web browsers will end "War for mobile" eventually
http://jacquesmattheij.com/Ios+Android+WP7+who+cares
http://jacquesmattheij.com/Ios+Android+WP7+who+cares
The Hundred-year Language
http://www.paulgraham.com/hundred.html
April 2003
Like species, languages will form evolutionary trees, with dead-ends branching off all over. We can see this happening already. Cobol, for all its sometime popularity, does not seem to have any intellectual descendants. It is an evolutionary dead-end-- a Neanderthal language.
........................
Main branches of the evolutionary tree pass through the languages that have the smallest, cleanest cores. The more of a language you can write in itself, the better.
April 2003
Like species, languages will form evolutionary trees, with dead-ends branching off all over. We can see this happening already. Cobol, for all its sometime popularity, does not seem to have any intellectual descendants. It is an evolutionary dead-end-- a Neanderthal language.
........................
Main branches of the evolutionary tree pass through the languages that have the smallest, cleanest cores. The more of a language you can write in itself, the better.
What is REST Services,RESTful
It stands for Representational State Transfer.
Like SOAP web services. It is Lightweight and Human Readable Results
It can be implemented in ASP.NET MVC.
Like SOAP web services. It is Lightweight and Human Readable Results
It can be implemented in ASP.NET MVC.
REST vs SOAP Web Services
Monday, March 28, 2011
How to prevent multiple shortcut events for JQuery Hotkeys plugin
$(document).bind('keydown', 'ctrl+s', function (e) {
DoSomethings();
e.preventDefault();
});
preventDefault method in javascirpt
event.preventDefault();
Cancels the event if it is cancelable, without stopping further propagation of the event.
Reference:
Sunday, March 27, 2011
Saturday, March 26, 2011
JQuery Hello world plugin
<div class="Test">
Hello world</div>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.js" type="text/javascript">
</script>
<script type="text/javascript">
(function($)
{
$.fn.helloworld = function()
{
return this.each(function()
{
$('div').css('color', 'red');
alert('Hello world');
});
};
})(jQuery);
$('.Test').mouseover(function()
{
$('.Test').helloworld();
});
</script>
Hello world</div>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.js" type="text/javascript">
</script>
<script type="text/javascript">
(function($)
{
$.fn.helloworld = function()
{
return this.each(function()
{
$('div').css('color', 'red');
alert('Hello world');
});
};
})(jQuery);
$('.Test').mouseover(function()
{
$('.Test').helloworld();
});
</script>
Reference:
Friday, March 25, 2011
How to handle Keyboard Shortcuts/hotkey in ASP.NET by JQuery Hotkeys
Download from:
$(document).bind('keydown', 'alt+ctrl+s', function () {
$('#elmentid').trigger('click');
});
Thursday, March 24, 2011
How to use CSS3 for progress bar
Demo
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='UTF-8'> | |
<title></title> | |
<style> | |
#loading-status { | |
width: 300px; | |
margin-left: 2px; | |
border: 1px #669CB8 solid; | |
-webkit-box-shadow: 0px 2px 2px #D0D4D6; | |
margin-top: 70px; | |
height: 20px; | |
-webkit-border-radius: 10px; | |
background: -webkit-gradient(linear, 0 0, 0 100%, from(#E1E9EE), to(white)); | |
padding: 1px; | |
} | |
#process { | |
background: -webkit-gradient(linear, 0 0, 0 100%, from(#7BC3FF), color-stop(0.5,#42A9FF), to(#7BC3FF)); | |
width: 0%; | |
height: 100%; | |
-webkit-border-radius: 10px; | |
/* -webkit-transition: width 1s ease-in-out; */ | |
-webkit-animation: load 1s ease-in-out infinite; | |
} | |
@-webkit-keyframes load { | |
0% { | |
width: 0%; | |
} | |
100% { | |
width: 80%; | |
} | |
} | |
.box { | |
height: 20px; | |
position: relative; | |
background: hsl(0, 0%, 35%); | |
-webkit-border-radius: 15px; | |
padding: 6px; | |
-webkit-box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.3); | |
width: 300px; | |
} | |
.box > span { | |
display: block; | |
height: 100%; | |
-webkit-border-top-right-radius: 8px; | |
-webkit-border-bottom-right-radius: 8px; | |
-webkit-border-top-left-radius: 15px; | |
-webkit-border-bottom-left-radius: 15px; | |
background-image: -webkit-gradient( | |
linear, | |
left bottom, | |
left top, | |
color-stop(0, #63DE4E), | |
color-stop(1, #34A702) | |
); | |
-webkit-box-shadow: | |
inset 0 2px 9px rgba(255,255,255,0.3), | |
inset 0 -2px 6px rgba(0,0,0,0.4); | |
position: relative; | |
overflow: hidden; | |
} | |
.animate > span > span { | |
content: ""; | |
position: absolute; | |
top: 0; left: 0; bottom: 0; right: 0; | |
background-image: | |
-webkit-gradient(linear, 0 0, 100% 100%, | |
color-stop(.25, rgba(255, 255, 255, .2)), | |
color-stop(.25, transparent), color-stop(.5, transparent), | |
color-stop(.5, rgba(255, 255, 255, .2)), | |
color-stop(.75, rgba(255, 255, 255, .2)), | |
color-stop(.75, transparent), to(transparent) | |
); | |
z-index: 2; | |
-webkit-background-size: 40px; | |
-webkit-animation: move 2s linear infinite; | |
-webkit-border-top-right-radius: 8px; | |
-webkit-border-bottom-right-radius: 8px; | |
-webkit-border-top-left-radius: 20px; | |
-webkit-border-bottom-left-radius: 20px; | |
overflow: hidden; | |
} | |
@-webkit-keyframes move { | |
0% { | |
background-position: 0 0; | |
} | |
100% { | |
background-position: 50px 50px; | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<div class="box animate"> | |
<span style="width: 80%"><span></span></span> | |
</div> | |
<div id="loading-status"> | |
<div id="process"></div> | |
</div> | |
</body> | |
</html> |
HTTPS is more secure, so why isn't the Web using it?
Can not be cached, cause performance issue.
http://arstechnica.com/web/news/2011/03/https-is-more-secure-so-why-isnt-the-web-using-it.ars
Perhaps the main reason most of us are not using HTTPS to serve our websites is simply that it doesn't work with virtual hosts. Virtual hosts, which are what the most common cheap Web hosting providers offer, allow the Web host to serve multiple websites from the same physical server—hundreds of websites all with the same IP address. That works just fine with regular HTTP connections, but it doesn't work at all with HTTPS.
There is a way to make virtual hosting and HTTPS work together—the TLS Extensions protocol—but Lafon notes that, so far, it's only partially implemented. Of course that's not an issue for big sites, which often have entire server farms behind them. But until that spec—or something similar—is widely used, HTTPS isn't going to work for small, virtually hosted websites
http://arstechnica.com/web/news/2011/03/https-is-more-secure-so-why-isnt-the-web-using-it.ars
Definitions for ASP.NET Viewstate
ASP.NET view state is the technique used by an ASP.NET Web page to persist changes to the state of a Web Form across postbacks
From:
ASP.NET page framework uses to preserve page and control values between round trips
Wednesday, March 23, 2011
How to add JavaScript function before request or after request for ACT Update Panel?
PageRequestManager
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args)
{
var elem = args.get_postBackElement();
ActivateAlertDiv('visible', 'AlertDiv', elem.value + ' processing...');
}
function EndRequestHandler(sender, args)
{
ActivateAlertDiv('hidden', 'AlertDiv', '');
}
In ASP.NET, ENTER key on a FORM with a single Input Field, will automatically SUBMIT.
This happens in IE, Chrome, but not in Firefox.
Solution: add another hidden input field. Such as:
<div style="display: none">
<input type="text" name="hiddenText" />
</div>
Reason:
Because IE and Chrome following HTML2.0 Specification exactly.
According to HTML2.0 Specification, 8.2. Form Submission:
When there is only one single-line text input field in a form, the
user agent should accept Enter in that field as a request to submit
the form.
Tuesday, March 22, 2011
CLEDITOR - JQuery WYSIWYG HTML EDITOR
CLEditor is an open source jQuery plugin which provides a lightweight, full featured, cross browser, extensible, WYSIWYG HTML editor which can be easily added into any web site
Demo
http://premiumsoftware.net/cleditor/
Demo
http://premiumsoftware.net/cleditor/
jQuery Mobile CDN
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" /> <script src="http://code.jquery.com/jquery-1.5.min.js"></script> <script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
Monday, March 21, 2011
How to find out common element(s) in two generic list by LINQ, LINQ Set Operations
int[] twos = { 2, 4, 6, 8, 10 };
int[] threes = { 3, 6, 9, 12, 15 };
// 6
var intersection = twos.Intersect(threes);
// 2, 4, 8, 10
var except = twos.Except(threes);
// 2, 4, 7, 8, 10, 3, 9, 12, 15
var union = twos.Union(threes);
Understand SQL Injection by code
If put the following string in the SSN text box
' ; DROP DATABASE pubs --
Using the input, the application executes the following stored procedure, which internally executes a similar SQL statement.
SqlDataAdapter myCommand = new SqlDataAdapter(
"LoginStoredProcedure '" +
SSN.Text + "'", myConnection);
The code INJECT into the user's malicious input and generates the following query.
SELECT au_lname, au_fname FROM authors WHERE au_id = ''; DROP DATABASE pubs --'
Reference:
How To: Protect From SQL Injection in ASP.NET
Sunday, March 20, 2011
How to select value into variable in MS SQL
Declare @RowCount int
set @RowCount = (select COUNT(*) from INFORMATION_SCHEMA.TABLES)
select @RowCount
set @RowCount = (select COUNT(*) from INFORMATION_SCHEMA.TABLES)
select @RowCount
Entity Framework 4.1 is coming with Code First feature
EF 4.1 includes the new “EF Code First” option that I’ve blogged about several times in the past. EF Code First provides a really elegant and clean way to work with data, and enables you to do so without requiring a designer or XML mapping file. Below are links to some tutorials I’ve written in the past about it:
http://weblogs.asp.net/scottgu/archive/2011/03/19/rc-of-entity-framework-4-1-which-includes-ef-code-first.aspx
http://weblogs.asp.net/scottgu/archive/2011/03/19/rc-of-entity-framework-4-1-which-includes-ef-code-first.aspx
Saturday, March 19, 2011
How to register multiple events into one handler in JQuery?
$('#foo').bind('mouseenter mouseleave blur', function() {
$(this).toggleClass('entered');
});
Programmers without computers
programmers need to stand up and think more.
http://www.johndcook.com/blog/2011/02/28/programmers-without-computers/
http://www.johndcook.com/blog/2011/02/28/programmers-without-computers/
How to upgrade an ASP.NET MVC 2 Project to ASP.NET MVC 3
ASP.NET MVC 3 can be installed side by side with ASP.NET MVC 2 on the same computer, which gives you flexibility in choosing when to upgrade an ASP.NET MVC 2 application to ASP.NET MVC 3.
To manually upgrade an existing ASP.NET MVC 2 application to version 3, do the following:- Create a new empty ASP.NET MVC 3 project on your computer. This project will contain some files that are required for the upgrade.
- Copy the following files from the ASP.NET MVC 3 project into the corresponding location of your ASP.NET MVC 2 project:
- /Scripts/jquery.unobtrusive-ajax.js
- /Scripts/jquery.unobtrusive-ajax.min.js
- /Scripts/jquery.validate.unobtrusive.js
- /Scripts/jquery.validate.unobtrusive.min.js
- /Views/Web.config
- If your ASP.NET MVC 2 project contains any areas, copy the /Views/Web.config file to the Views folder of each area.
- In both Web.config files in the ASP.NET MVC 2 project, globally search and replace the ASP.NET MVC version. Find the following:
System.Web.Mvc, Version=2.0.0.0
Replace it with the following:
System.Web.Mvc, Version=3.0.0.0
- In Solution Explorer, delete the reference to System.Web.Mvc (which points to the DLL from version 2), then add a reference to System.Web.Mvc (v3.0.0.0).
- Add a reference to System.WebPages.dll and System.Web.Helpers.dll. These assemblies are located in the following folders:
- %ProgramFiles%\ Microsoft ASP.NET\ASP.NET MVC 3\Assemblies
- %ProgramFiles%\ Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies
- In Solution Explorer, right-click the project name and then select Unload Project. Then right-click the project name again and select Edit ProjectName.csproj.
- Locate the ProjectTypeGuids element and replace {F85E285D-A4E0-4152-9332-AB1D724D3325} with {E53F8FEA-EAE0-44A6-8774-FFD645390401}.
- Save the changes, right-click the project, and then select Reload Project.
- In the application’s root Web.config file, add the following settings to the assemblies section.
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
- If the project references any third-party libraries that are compiled using ASP.NET MVC 2, add the following bindingRedirect element to the Web.config file in the application root under the configuration section:
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0"/> </dependentAssembly> </assemblyBinding> </runtime>
Reference:
http://www.asp.net/learn/whitepapers/mvc3-release-notes#upgrading
Friday, March 18, 2011
Next ASP.NET version will include important features from MVC
Despite the excitement around MVC, ASP.NET WebForms are still very popular. According to Evonet Consulting, the next major ASP.NETrelease will contain a number of features originally introduced in MVC, including Model Binders, unobtrusive client-side validation, and CSS sprites.
How to implement TSQL in clause by LINQ, Contains Method of List(Of T)
string[] countrycode = null; countrycode = listofcountrycodes.Split(',');
dataSource.StateList.Where(s => countryCodes.Contains(s.CountryCode))
How to detect mouse right click paste event in JQuery ?
$('#controlId').bind('paste', null, function(e) { if(!e.keyCode){ /* since no key was down at the time of the event we can assume it was from the toolbar or right click menu, and not a ctrl+v */ } });
http://rayaspnet.blogspot.com/2011/01/how-to-implement-textchanged-event.html
Entity framework does not support mapping an int column to Enum
Solutions:
Use a Foreign Key to a reference table and model this with an association (which is completely overkill).
Two ways for Workarounds
http://cticoder.wordpress.com/2008/08/16/using-enums-with-entity-framework/
http://blogs.msdn.com/b/alexj/archive/2009/06/05/tip-23-how-to-fake-enums-in-ef-4.aspx
Use a Foreign Key to a reference table and model this with an association (which is completely overkill).
Two ways for Workarounds
http://cticoder.wordpress.com/2008/08/16/using-enums-with-entity-framework/
http://blogs.msdn.com/b/alexj/archive/2009/06/05/tip-23-how-to-fake-enums-in-ef-4.aspx
IE9 CSS3 selector and HTML5 test result
CSS3 Selectors Test:: 100%
http://tools.css3.info/selectors-test/test.html
HTML5:
155 out of 400
http://html5test.com/
http://tools.css3.info/selectors-test/test.html
HTML5:
155 out of 400
http://html5test.com/
IE9 Speed test, V8
IE 9 is better than Firefox, worse than Chrome
http://v8.googlecode.com/svn/data/benchmarks/v6/run.html
http://v8.googlecode.com/svn/data/benchmarks/v6/run.html
Thursday, March 17, 2011
CSS3 Rounded corners in IE9
The border-radius properties enable you to curve border corners by essentially “replacing” the hard corners with a quarter-ellipse and specifying the radii of each ellipse. The properties consist of the following:
Reference:
http://msdn.microsoft.com/en-us/ie/ff468705#_CSS3_BG_Borders
- border-radius (The value given will specify the radius for all four corners of a box.)
- border-bottom-left-radius
- border-bottom-right-radius
- border-top-left-radius
- border-top-right-radius
border-radius: 100px 66.66px 200px 50px; border: 10px blue double; padding: 24px; width: 400px;height: 125px;
Reference:
http://msdn.microsoft.com/en-us/ie/ff468705#_CSS3_BG_Borders
Wednesday, March 16, 2011
How to check if an argument is not a number in Javascript
isNaN function
isNaN("string") //returns true
isNaN("12") //returns false
Null-coalescing operator, Double question mark( ??) in C#
int? x = null;
Console.WriteLine(x?? 100);
Equal:
var test = (x == null) ? x : 100;
Reference:
How to show a heavy-data gridview not in page load, to prevent freezing page?
<asp:UpdatePanel ID="UpdatePanelMemberList" runat="server" UpdateMode="Conditional">
<contenttemplate>
<asp:GridView runat="server"/>
</contenttemplate>
</asp:UpdatePanel>
<asp:HiddenField ID="H1" runat="server" />
- After page loaded in html trigger button click event
$(document).ready(function () {
var hidenv = $("#<%=H1.ClientID %>").val();
if (hidenv != 'show') return;
$("#<%=Submit.ClientID %>").trigger('click');
});
How to show progress in ASP.NET WebForms by UpdatePanel
<script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(prm_InitializeRequest);
prm.add_endRequest(prm_EndRequest);
function prm_InitializeRequest(sender, args) {
var panelProg = $get('divImage');
panelProg.style.display = '';
}
function prm_EndRequest(sender, args) {
var panelProg = $get('divImage');
panelProg.style.display = 'none';
}
</script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="divImage" style="display:none">
<asp:Image ID="img1" runat="server" ImageUrl="~/images/progress.gif" />
Processing...
</div>
<br />
<asp:Button ID="btnInvoke" runat="server" Text="Click"
onclick="btnInvoke_Click" />
</ContentTemplate>
</asp:UpdatePanel>
Subscribe to:
Posts (Atom)