Jan
7
This is the first blog post in a series of "Social Media Integration" schtuff that I have been working on lately. What I will tackle first is the Twitter integration, which at first seemed really hard, but with a bit of perseverance is now so simple I could cry.
Twitter Applications
To start a Twitter application, firstly log into Twitter and then go to http://twitter.com/oauth where you can register a new application. I haven't used the "User twitter for login" yet so we won't be discussing that today. If you want your application to be able to update a user's feed, then you must set Read & Write. If you think you will only want to read from a user's twitter account then setting Read Only makes your code more secure, i.e. you can't accidentally change things. Twitter will now give you your Consumer Key and Consumer Secret. Place that somewhere safe and within a config file of your application. I don't know why they also show the three URLs as its not very helpful until you have read the API documentation or even blogs like this one (or only this one as the others are rubbish!). The URLs are not even in order. The order should be :
- Request token URL - your application requests this
- Authorize URL - your user clicks this URL in your application with the token you retrieved in number 1
- Access Token URL - your application then takes the output from number 2, calls this URL and saves the result!
So how did placing those 3 urls on the page help you? It didn't!
Read more »
a93de457-0a84-4534-b33a-c72517478dc6|0|.0
Aug
6
Something a lot of us do is create SQL statements inline or in stored procedures but never really think of what is happening. When you create a simple stored procedure like:
SELECT * FROM MyTable
what happens is that SQL Server (am not sure about other databases sorry) goes off, checks a couple of previous statement calls incase it has already got an execution plan for this stamtent, runs the statement, and returns the result. However the results that it sends back contains more data than we need most of the time.
By adding the following
SET NOCOUNT ON
At the top of your SQL Store Proc or statement if inline, you can reduce the amount of network traffic. If your site is heavily hit and you haven't got a proper caching system in place, this could help speed up your site.
8953d1c7-d309-4a72-8f85-84694b5b2120|0|.0
Aug
5
Ever built a usercontrol or webpage and had a repeater? Did that repeater have an item and alternating item template? And were those templates exactly the same except for the class on the row or li element? Well I have, and for years I cried when I had to update the repeater.
<ItemTemplate>
<tr class="row">
<td style="text-align: center;">Some Code or other HTML</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr class="rowalt">
<td style="text-align: center;">Some Code or other HTML</td>
</tr>
</AlternatingItemTemplate>
Well I found the simplest way to fix this was with C# and a ? notation and some inline coding. Yes inline coding. Doesn't that break paradigms of keep C# in the code behind and so forth? Well I have views on this and may at some point blog on it, but today let's just say yes, yes it does. But the rules are there to be broken.
The Solution
Container.ItemIndex % 2 == 0 ? "row" : "rowalt"
Yes it's that simple! By replacing the value in the "class" tag in your HTML with that you get a more concise piece of code. It basically says "Take the row index of the current row, divide it by 2. If you have no remainder, then its an even number and so output 'row' otherwise output 'rowalt'."
<ItemTemplate>
<tr class='<%# Container.ItemIndex % 2 == 0 ? "row" : "rowalt" %>'>
<td style="text-align: center;">Some code or other HTML</td>
</tr>
</ItemTemplate>
Roll on the next version of CSS to make this even easier. It's also possible in Javascript libraries like MooTools or jQuery to do this, but this is the simplest option in my opinion.
a94c996d-680d-41b1-8bbd-52ca08ba7575|0|.0
May
14
For a while now we have been playing with heat mapping from a third party company, Click Density.

It works real well, and you can really see how your users are using your site (else they really wouldn't be users! - ed.). But with multiple sites under our belt and swathes of sites coming our way we wondered how easy it would be to create something that we could plug'n'play with.
Generic Handlers
.Net comes with a great file type called a generic handler (*.ashx) which allows you to send back to the requestor any type of file that you want to send back to them. This could be XML, JSON or even an image. But all we need to send back is Javascript.
At first we thought this would be cross domain scripting which is not allowed, but actually its just popping a URL onto someone's page and the Javascript would run.
<script src="http://where.your-generic-handler-is-hosted.com/js.ashx?clientId=2" type="text/javascript" language="javascript"></script>
But will we be able to inject HTML and Script tags into the page as well?
Read more »
34437562-d3eb-420f-a402-27d0b6c91ad4|0|.0