Digital Tool Factory blog - Page 17 of 34 - Backend web development in Atlanta GA Digital Tool Factory blog - Page 17 of 34 - Backend web development in Atlanta GA

The Digital Tool Factory Blog

How to do a cool flash notification message in asp.net mvc 3 in 6 easy steps

I pieced all of this together from various sources online, so the code is a bit rough, but here it is:

1.  Create a partial razor view, call it _NotifyBar.cshtml, it contains this:

@if (Request.Cookies[“NotifyBar”]!=null)
{

var c = new HttpCookie(“NotifyBar”);
c.Expires = DateTime.Now.AddDays( -1 );
Response.Cookies.Add( c );

}

2.  Put this in the header of your _Layout.cshtml file
//here is the jbar stuff

<script type=”text/javascript”>//
$(document).ready(function () {
$(“#message”).fadeIn(2000);
$(“#message”).delay(5000).fadeOut(1000);
$(“#message a.close-notify”).click(function () {
$(“#message”).fadeOut(“slow”);
return false;
});
});
</script>

3.  Right after the body of your _Layout.cshtml page there is this code

@Html.Partial(“_NotifyBar”)

4. Create a file called ExtensionMethods.cs, add in this code

public static ActionResult SetStatusMessage(this ActionResult ar, string str)
{
var c = new HttpCookie(“NotifyBar”);
//c.Expires = DateTime.Now.AddDays(-1);
c.Value = str;
HttpContext.Current.Response.Cookies.Add(c);
return ar;
}

5. Put this in your stylesheet

#message {
font-family:Arial,Helvetica,sans-serif;
position:fixed;
top:0px;
left:0px;
width:100%;
z-index:105;
text-align:center;
font-weight:bold;
font-size:100%;
color:white;
padding:10px 0px 10px 0px;
background-color:#8E1609;
}

#message span {
text-align: center;
width: 95%;
float:left;
}

.close-notify {
white-space: nowrap;
float:right;
margin-right:10px;
color:#fff;
text-decoration:none;
border:2px #fff solid;
padding-left:3px;
padding-right:3px
}

.close-notify a {
color: #fff;
}

6. Then in your controller, just return add “SetStatusMessage” on your RedirectToAction, for example

return RedirectToAction(“Index”).SetStatusMessage(“You have successfully edited the ” + project.ProjectName + ” project.”);

That’s it!  You can now have a fade-out notification message on any page you like.  The use of the cookies is a bit cumbersome, but I could implemnt it quickly.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


24
May 11


Written By Steve French

 

How to Fix the “Service Unavailable” problem in IIS

Gears gears cogs bits n piecesThe Problem: For whatever reason, your website is displaying a white screen with “Service Unavailable” and nothing else.

The Cause: There could be many causes, but the one I just discovered was that the application pool had shut down for no good reason.

The Solution: In IIS, navigate to “Application Pools”, right click to bring up the content manager – select “Stop”, and then select “Start”.  That should fix the problem in most cases.

Creative Commons License photo credit: Elsie esq.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


23
May 11


Written By Steve French

 

How to create a asp.net gridview hyperlink field with multiple querystring parameters

Frozen linksThe Problem: You need to put a relatively complicated link (i.e. the link has more than one parameter) into an asp.net gridview column.

The Cause: No cause really, you just need to know the exact syntax
The Solution:

<asp:HyperLinkField HeaderText=””

Text=”Download Your File”

DataNavigateUrlFields=”CategoryID,FileID”

DataNavigateUrlFormatString=”FileDownloader.

aspx?catid={0}&file={1}” />

You can have as many fields as you like in the DataNavigateUrlFields tag, and it will simply autopopulate from that point on (provided you have the parameters in proper {0} fashion.  This is hardly the biggest problem I’ve ever faced, but I didn’t know how to create the Hyperlink field in that way and now I do.
Creative Commons License photo credit: skedonk

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


19
May 11


Written By Steve French

 

An argument for .Net in startups – to wit, avoiding groupthink

Vikings!I recently read Why Startups Could Use .NET, But Don’t and the original CEO Friday: Why we don’t hire .NET programmers post from Expensify.  For a quick summary

Starting Fact:

  • Startups are risk taking places
  • Startups are founded by risk taking people

Pros of .Net

  • Great Tools
  • Works together well
  • .Net programmers know how to use the platform

Cons of .Net

  • .Net programmers are stodgy
  • And risk averse
  • And see no need to tweak solved problems like the networking stack

(Granted, I am biased as a .net developer.)

From which I drew the conclusion: The technology is, if anything, better, but the non .Net people are more similar to risk-taking startup CEO types, so they fit into the startup culture much better.

Now that I think about it, that seems to be an argument FOR startups developing on the .Net platform.  The risk taking CEO is a given, if you also bring in like-minded developers then the startup will have more group think, and consequently make poorer decisions than a more diverse mix of personalities.

Now that I read this again, this is an empirical question – What proportion of .Net based startups reach profitability vs the non .Net startups?  Do(es) the data exist anywhere?

Creative Commons License photo credit: hans s

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


17
May 11


Written By Steve French

 

Fix the problem and move on

I recently ate breakfast with a few other local business types (one the head of the best event staffing company in Atlanta) and one of them presented an interesting problem.  He told the story of a former staff member who had made what seemed (to him)  to be an obvious mistake.  He seemed to think that this was caused by an inborn flaw that could never be fixed.  The dilemma, should he have gotten rid of the staffer or worked around the staffer?   The majority of people agreed with the inborn flaw theory, but that he should just work around the flaw.

I thought that the problem was fundamental attribution error, (attributing the problem to the person and not the situation).  He thought that the former staffer possessed no initiative.  My initial thought (from his description of the situation) was that the staffer was confronted with an unclear situation and he had no obvious way to show initiative.

Upon further thought,  in real world situations, there is no way to ever determine which one of us is right, and the best thing to do it just put the solution to the problem in a checklist or manual and move on.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


16
May 11


Written By Steve French

 

How to fix problems with asp.net mvc 3 charts and razor pages

The Problem: You attempt to use the super-cool new charting features in asp.net mvc 3, and all you get is compilation errors

The Cause: You are using the old school System.Web.UI.DataVisualization.Charting.Chart namespace

The Solution: Delete

using System.Web.UI.DataVisualization.Charting.Chart

and instead insert

using System.Web.Helpers;

If you are using the chart code in an actual razor page (and not in the controller), just insert

@using RazorHelpers.Helpers

into the top of the page

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


06
May 11


Written By Steve French

 

Rural vs City life – or how much culture do you care to contribute?

I recently came across this Simple Dollar blog post – “Why I Prefer Living Rural” and largely agreed with it.  I did have two quibbles.

  1. There was no mention of privacy and anonymity, the two greatest things about living in the city.  It is impossible to keep your life exclusively yours in the county.  Lots of people like being in a close community, but I enjoy living unknown.
  2. Culture – the problem with the country is not the lack of “culture”, but rather one must actively participate in cultural activities if you want to have any.  In the city culture is passive, in the country it’s something you make.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


26
Apr 11


Written By Steve French

 

The five kinds of Facebook status updates

They are all some variation of the following:

  1. I have friends and we like to have fun!
  2. My possessions make me so happy!
  3. Join me in my outrage at a gross mis-characterization of a news story I found online
  4. While the number of things I have to say is at zero, my desire to talk is at 10.  Therefore please enjoy this YouTube link
  5. I’m about to do something I don’t know anything about, please offer a technical opinion so if anything goes wrong I can blame someone.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


21
Apr 11


Written By Steve French

 

How to fix port forwarding problems with Clear Wireless

774 - Neuron Connection - Pattern
The Problem:
You use Clear Wireless (ClearWire) for your internet service and you cannot set up Remote Desktop on Windows 7.

The Cause: Whereas most internet provider provided devices just function as gateways, the Clear device functions as both a router and a gateway rolled into one unit.   It also uses a different subnet.  You also have to use a separate router with the Clear device if you have more than one computer (what fun).

The Solution: Just point all relevant traffic from the Clear device to your normal router, and set up your computer normally from there.

Creative Commons License photo credit: Patrick Hoesly

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


19
Apr 11


Written By Steve French

 

What you need to know about REST

I was going to start a new category on the blog entitled “What You need To Know”, and have the first entry be about the computer science notion of REST (by which I mean Representational State Transfer) but I could never top this this blog post How I Explained REST to My Wife – it’s absolutely brilliant.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


02
Mar 11


Written By Steve French

 




Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.