getsetcode
Observations of a C# .NET web developer collective.
4 Dec 2013
Use transforms with any XML file in Visual Studio, not just web.config
Yesterday I discovered a handy little Visual Studio extension called, for some reason, SlowCheetah. Once installed you can right-click any XML file (usually you'll use this for config files) and get an 'Add Transform' option.
This allows you to use the XML transform notation so that published sites will pick up the correct settings based on the configuration used. It also means you won't be publishing files containing settings for other environments.
Nice!
17 Apr 2013
Responsive design infographic
I just stumbled across this great infographic containing 10 top tips for building responsive layouts. Great place to start.
28 Mar 2013
General programming rules #1
Don't use boolean method parameters.
Why? Because it makes your code unreadable and inextensible.
e.g. render(true) is meaningless but render(PageMode.Readonly) is semantic and unambiguous.
26 Mar 2013
Post an array in integers using Jquery & Ajax to MVC controller action
Mvc Action
public JsonResult Receive(int[] ages) { return Json(string.Format("ages {0} received", String.Join(",",ages))); }
Jquery Code
$(function() { $("#PostArray").click(function() { var arr = new Array(); arr.push(1); arr.push(21); arr.push(23); $.ajax({ url: '/Home/Receive', type: 'POST', contentType: 'application/json', dataType: 'json', data: JSON.stringify({ages: arr }), success: function(data) { alert(data); } }); }); });Download Example
List of ASP.NET Web API and HttpClient Samples
I just came across this massive list of web API code samples which is well worth a gander if you're looking at API development. And let's face it, in this new mobile age no developer can really be without this knowledge.
25 Mar 2013
Entity Framework 5 Many to Many relationship setup
Sample Solution Download Link
How to setup entity framework objects for many to many relationship.
I had a problem trying to get this to work but after I managed to get it working
I decided to post the solution here with a hope that it will help someone someday.
To begin.
1. Download the solution (it is a vs-2012 solution) & unzip accordingly
2. Create a database called (EdkSamples)
3. Create a login (user: developer, password: letmein$123)
4. Create database tables using the scripts
Edikgale.Samples.Data\Database Setup\DatabaseCreate.sql
5. Initialise the database data with the script in folder
Edikgale.Samples.Data\Database Setup\DataSetup.sql
6. To see how this works simply run the test in
EdwardDikgale\Edikgale.Samples.Data.Tests\EdikgaleEfContextTest.cs
Note
1. The test project uses a connection string defined in App.config which
you may wish to adapt accordingly.
2. The linking table is not modelled as a poco object because there is no need to unless
you happen to have some extra properties on it.
if you have any problems feel free to email me: edward.dikgale@gmail.com
I hope this helps you in some way
Ed
posted by: Edward Dikgale
How to setup entity framework objects for many to many relationship.
I had a problem trying to get this to work but after I managed to get it working
I decided to post the solution here with a hope that it will help someone someday.
To begin.
1. Download the solution (it is a vs-2012 solution) & unzip accordingly
2. Create a database called (EdkSamples)
3. Create a login (user: developer, password: letmein$123)
4. Create database tables using the scripts
Edikgale.Samples.Data\Database Setup\DatabaseCreate.sql
5. Initialise the database data with the script in folder
Edikgale.Samples.Data\Database Setup\DataSetup.sql
6. To see how this works simply run the test in
EdwardDikgale\Edikgale.Samples.Data.Tests\EdikgaleEfContextTest.cs
Note
1. The test project uses a connection string defined in App.config which
you may wish to adapt accordingly.
2. The linking table is not modelled as a poco object because there is no need to unless
you happen to have some extra properties on it.
if you have any problems feel free to email me: edward.dikgale@gmail.com
I hope this helps you in some way
Ed
posted by: Edward Dikgale
15 Mar 2013
100 Cool jQuery Plugins
Here's a great resource - 100 cool (and, in some cases, super-cool) jQuery plugins
Subscribe to:
Posts (Atom)