code complete 2

If you have not read this book, please stop what are you doing now and read it. After that, at the final, you will find another good reccomandations.

Now the summer holiday is coming – buy it , read it and discuss it.

powershell and clean iis

Sometimes it is necessary to remove IIS temp files from windows directory

So I have made this following script in powershell

iis reset

What it does:
restarts iis ( run as admin in Windows 7)

Cleans temporary folders from

$windir + “\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files”

$windir + “\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files”

Enjoy !(iis reset)

String Truncate in MVC

I always wanted a string truncate  – i.e.,  if you have a long string, to have “show less” and “show more”.

So I have decided to do it .

1. See in action first:


And after click:


2. How can you use in your MVC projects:

Add in your project the \Views\Shared\DisplayTemplates\StringTruncate.cshtml file ( in this folder!) and put
@Html.DisplayFor(m => m.String1, “StringTruncate”)

3. Code: It implies only a div and a hidden – and javascript, of course.

@model string

    string id = ViewData.ModelMetadata.PropertyName;
   string textFull = Html.Encode(Model??"");
   string PartialText = textFull;
   string less = "";
   bool full = true;
   if (PartialText.Length > 20)
       full = false;
       PartialText = PartialText.Substring(0, 20) + "...<a href=javascript:showHide_" + id + "(true)>(more)</a>";


<div title="@textFull" id='@("display"+ id)'>
        @Html.Raw(PartialText )

    @{if (full) {

<div  id='@("hid" + id)' style="display:none">
<p><a href='javascript:@("showHide_"+ id) (false)'>less</a></p>
<script type="text/javascript">
function @("showHide_"+ id) (showFull){

$("#@("display"+ id)").toggle(!showFull);

$("#@("hid"+ id)").toggle(showFull);


4. Source code here:

string Truncate

5. TODO ( homework):

Modify the source in order to have one javascript and send the ids of the hidden and of the div to the function.

friday links 30


  1. Managed Extensibility Framework – Building Composable Apps in .NET 4 with the Managed Extensibility Framework
  2. EntityFunctions Methods (System.Data.Objects)
  3. ANTS Performance Profiler for profiling your .NET code – Ahead of the game poster
  4. Siri knows which is the best phone ever, and its not the iPhone | WMPoweruser
  5. How to get your app into the Windows Store – Matt Harrington – Site Home – MSDN Blogs
  6. Visual Studio Gallery
  7. In Memoriam: Our Favorite Apps and Services That Have Gone Belly Up (and Their Replacements)
  8. TFS Power Tools 2008 Powershell Snapin won’t run in on 64-bit in Windows 2008 R2?
  9. Programing issues: Performance Counter Setup on Windows Azure
  10. Free E-Books from Microsoft Press | Mike Hacker
  11. Why Nikola Tesla was the greatest geek who ever lived – The Oatmeal
  12. How a Web Design Goes Straight to Hell – The Oatmeal
  13. Knockout 2.1 is out – Knock Me Out
  14. ASP.NET Web API Updates – May 14 – Henrik’s Blog – Site Home – MSDN Blogs
  15. Sample Code – MSDN Examples in C#, VB.NET, C++, JavaScript, F#
  16. Kendo Blog Posts > Hello Services / WebAPI, REST, JSON and AJAX
  17. My First Experience with ASP.NET Web API 101 : Sam Gentile’s Blog
  18. Free .NET decompiler :: JetBrains dotPeek
  19. AJAX File Uploads with jQuery and MVC 3
  20. Optimistic concurrency support in HTTP and WebAPI – part 2 | Tudor Turcu – blog
  21. 15 Things You Should Give Up To Be Happy
  22. Blogging about : Adding Gravatar To An ASP MVC Project
  23. Blogging about : Create a Selfexpanding Textarea using Javascript
  24. Introducing GitHub For Windows
  25. Parse
  26. Additional Considerations When Using ASP.Net MVC Cross-site Request Forgery Prevention – Ed Hintz (MSFT) – Site Home – MSDN Blogs
  27. What The Fuck Is My Career Objective
  28. IIS 7.0 Server-Side : IIS 7.0 Two-Level Authentication with Forms Authentication and Windows Authentication

expand collapse with jquery

If you have a text that you want to hide and show to a click of a hide/show, put this code fast: ( instead of @Url.Content you can use <%=ResolveUrl ) [code lang="HTML"] <a href="javascript:ShowHide('the_id_of_the_element_to_be_show_or_hide', this)"> <img border="0" src='@Url.Content("~/Content/images/show.gif")' title = 'show hide'> </a> <div id='the_id_of_the_element_to_be_show_or_hide' style='display:hidden'> this is hidden content - will be displayed </div> [/code] [code lang="Javascript"] <script type="text/javascript"> var imgShow = '@Url.Content("~/Content/images/show.gif")'; var imgHide = '@Url.Content("~/Content/images/hide.gif")'; function ShowHide(id, img) { var element = $("#" + id); element.toggle('slow', function () { if (":hidden")) { img.src = imgShow ; } else { img.src = imgHide ; } } ); } </script> [/code]

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.