Netferrets Online Blog, Internet Related Programming Solutions, Created in C# .net, VB .net, MS SQL Server Javascript, HTML and CSS. Proving sample solutions to problems found when creating web application solutions.
Wednesday, 11 December 2013
Umbraco UserType.GetType Error/Problem is not an instance of an object
I was trying implement the creation of users from a csv file directly into umbraco and doing a unit test. Unfortunately it doesn't allow that functionality out of the context of the website, I only realised this after a few hours of trying to fiddle around.
I am sure there is a way to do this in version 6, as they have the contentservice etc, but I am yet to find the answer, until then for testing this sort of functionality its going to have be driven through the website.
If anyone has any ideas then please feel free to let me know.
Thanks.
Tuesday, 10 December 2013
Visual Studio 2012 Update 4 - Retry Errors
There are quite a few fixes out for this, but I will put my 2 pence worth out there.
Basically I am using windows 8 and all I needed to do was uninstall the stupid AVG safebar, which I have no idea why its running because I already uninstalled AVG. Also I stopped the windows install via the task manager.
Once I ran the installation again it worked and it didnt require a reboot to get it to start installing which is always nice :)
Friday, 2 August 2013
Operator '!=' cannot be applied to operands of type 'string' and 'System.DBNull'
simply use
Convert.IsDBNull(field) ? 0 : field;
simples :D
Thursday, 1 August 2013
Facebook locale information and cultureinfo to get country in .net
You will need this in your code behind:
using System.Globalization;
'en_GB' will be replace so .net can understand the format, this was from a dynamic type, but you can use just a string if you wish.
var country = CultureInfo.GetCultureInfo(locationinfo["locale"].Replace("_", "-")).EnglishName;
string countryName = country;
countryName = countryName.Substring(countryName.IndexOf("(") + 1, (countryName.Length - countryName.IndexOf("(")) - 2);
Instead of returning 'English (United Kingdom)' it will now return 'United Kingdom' only.
This has several uses, but I needed it to reference the city and country from facebook to a google map. I had the city information, but the main issue was getting a clean country name which is why this was needed because city names can appear in different countries.
I will probably go into further detail as some point as to what can be achieved with these.
Wednesday, 17 July 2013
Umbraco - uTwit - Fun and Games - Errors, Bad Request Etc
After messing around with uTwit and reading a lot of other posts, I finally managed to get it going.
The following script actually works, others have posted similar scripts, but they always seem to be missing something. You have to setup a twitter account and goto dev.twitter, setup an application, setup a callback url(can be anything, but needs to be there), generate auth details.
Few things to check, make sure you have installed the Uwit package datatype etc. Add the property for example to your homepage which is what I have done in this case called 'twitter'. You install using the .zip files, I didn't realise this at first, lol :D
The home node is the id that you will need to reference, I have tried to cover all bases here as I appreciate everyone has different uses and implementations. Hopefully this will all make sense. There are commented out lines should you need to hardcode or called a specific node id.
You will need to add the following references to you project:
Our.Umbraco.uTwit.DataType.dll
Our.Umbraco.uTwit.Web.dll
@inherits umbraco.MacroEngines.DynamicNodeContext
@using Our.Umbraco.uTwit
@using umbraco.NodeFactory
@{
const string twitterOAuthPropertyAlias = "twitter";
const int numberOfTweetsToDisplay = 3;
const bool includeReplies = false;
const bool includeRetweets = true;
// Get current node
Node home = umbraco.NodeFactory.Node.GetCurrent();
// Alternatively if you have a settings node for example use a specific id
//var home = Model.NodeById(1079);
// If you want to hard code the details then use this line
// string twitterOAuth = "{'ScreenName': 'xxx','OAuthToken': 'xxx','OAuthTokenSecret': 'xxx','ConsumerKey': 'xxx','ConsumerSecret': 'xxx'}";
string twitterOAuth = home.GetProperty(twitterOAuthPropertyAlias);
// If you use a specific node ID then use this instead
//string twitterOAuth = home.GetPropertyValue(twitterOAuthPropertyAlias) as string();
var config = uTwit.DeserializeValue(twitterOAuth);
var tweets = uTwit.GetLatestTweets(config, numberOfTweetsToDisplay, includeReplies, includeRetweets);
if (tweets != null)
{
foreach (var tweet in tweets)
{
var tweetToDisplay = tweet.IsRetweet ? tweet.RetweetedStatus : tweet;
@tweetToDisplay.User.Name
@uTwit.FormatDate(tweetToDisplay.CreatedAt)
}
}
}
Hope this saved some of you some headaches when it wasn't working.
@tweetToDisplay.LinkifiedText
@if(tweet.IsRetweet) { }Monday, 15 July 2013
__doPostBack is not defined
If you using chrome check User Agent Switcher plugin, After removing this the error magically disappeared.
There are several other solutions to this problem, but its not worth me resisting them here.
Sunday, 14 July 2013
Jquery, resize li tags automatically
Heres a bit of code I put together to stretch a menu to to the full width of the page regardless of how many items there are.
var orginalwidth = $(".nav").width;
var newwidth = 100 / $(".nav li").length;
$(".nav li").each(
function () {
$(this).css("width", newwidth + "%");
}
)
Subscribe to:
Posts (Atom)