Sunday, August 26, 2012

New Website Launched

A new website has been launched today for Westbourne Motors in Seaton Delaval.

Preview the website live at www.westbournemotors.com

Sunday, August 19, 2012

Limit string lengths in C# adding Ellipsis (...) text

The following snippet of code can be used to limit the lenth of strings in a paragraph of text using C#.

The code will add ellipsis (or '...') characters to the end of the string.

Happy coding

public static string Ellipsis(string originalText, int length)
        {
            if (originalText.Length <= length) return originalText;
            int pos = originalText.IndexOf(" ", length);
            if (pos >= 0)
                return originalText.Substring(0, pos) + "...";
            return originalText;
        }

Tuesday, April 10, 2012

Detecting Browser Display Width Using Jquery - Responsive Design

I have recently been working on a project that needs to be 'responsive' dependent on the visible browser area, I have written some Jquery code that detects the user's browser display width and disables or enables stylesheets as required, I have included a snippet below should this help anyone.

function ProcessPageSize() {

//Configure stylesheets based on visible area.

setStyleEnabled("deskStyle", true);
setStyleEnabled("deskStyle2", true);
setStyleEnabled("handheldStyle", false);
setStyleEnabled("tabletStyle", false);

//get window width
var width = $(window).width();

if (width < 960) {
setStyleEnabled("deskStyle", false);
setStyleEnabled("deskStyle2", false);

if (width < 400)
setStyleEnabled("handheldStyle", true);
else
setStyleEnabled("tabletStyle", true);
}

}

function setStyleEnabled(styleName, isEnabled)
{
$('link[@rel*=style][title]').each(function (i) {
this.disabled = true;
if (this.getAttribute('title') == styleName) this.disabled = !isEnabled;
});
}

//Call configure page function
$(document).ready(function () {
ProcessPageSize();

$(window).resize(function () {
//resize just happened, pixels changed
ProcessPageSize();
});



});

See a jpr freelance - built responsive design in action - here

Responsive Design

JPR freelance are currently working on a cutting edge website build using responsive design techniques and CSS media queries.

The mobile and tablet market is ever-increasing and it is important that sites are built to accommodate the mobile market, building a site with CSS media queries allows us to alter graphical display based upon a client's device display size.

For more information on responsive web design visit the following wiki article:

http://en.wikipedia.org/wiki/Responsive_Web_Design

Friday, May 27, 2011

Freelance Web Developer Bubble


JPR Freelance have now purchased a new vehicle for advertising use!

Known in the office as the JPR Freelance 'bubble', the Fiat 500 is fully badged up to catch people's eye when travelling the streets of Tyneside and beyond!

Wednesday, May 18, 2011

From Freelance Web Developer's Office To Film Set!

Yesterday saw the arrival of a German film company to JPR Freelance offices in North Shields, near Newcastle upon Tyne. The company have converted the JPR Freelance offices to a bakery and an internet cafe!

Watching the crew work was most interesting, it is quite amazing how a block of offices can be converted in a day to look completely different. Just look at the photos of the set!





Monday, May 2, 2011

Passing Selected HTML.Dropdownlist through actionlink in MVC

I spent a bit of time today figuring out how to pass a selected value from an html dropdown list into an MVC actionlink so thought I would write a post on my findings.

OK, I have a category list on my page as follows:

<%:Html.DropDownList("Categories") %>

...and an actionlink link as follows:

<%: Html.ActionLink("Edit", "MaintainCategory", "CMS", new { ID = 0 }, new { id = "editlink" })%>

...I want the ID passed to be the value selected in the dropdown box.

The easiest way I found was to add the above JQuery / Javascript to the page:

<script type="text/javascript">

$(function () {
$('#Categories').change(function () {
var value = this.value; // get the selected value
//modify the href link
value = '/CMS/MaintainCategory/' + value;
$('#editlink').attr('href', value);

});
});