Monday, September 24, 2012

Reading Information from a webconfig file in asp.net

Every once in a while, we would like to keep some of the application settings in a web config file to handle tasks like Database location and file location. Here is a quick way too read from a Web.config file  

<!-- Somewhere in the web.config fole -->
  <appSettings>
    <add key="NameOfTheKey" value="Value"/>
    <add key="FooKey" value="\\folder\Shared Documents"/>
  </appSettings>


Here is how to get the file in C#


string location = WebConfigurationManager.AppSettings["NameOfTheKey"]; //location will be "Value"

Hope that helps

A Web Afternoon - Notes

I went to a (surprisingly) fun event last weekend. The best way to describe it is it is a series of TED videos all talking about the web (with great cake and coffee in the back of the room).  Hopefully, you can follow these amazing speakers and get caught up on what you missed. I highly recommend going to the future A Web Afternoon events.


below are some of the quotes that I was able to doodle down (I really have no idea how to summarize this). I am sorry if I am misrepresenting any of the sessions or misquoting anyone.

===
Speaker: Jensen Inman
Contact: @edae
Topic:Be Awesome
"if you find yourself smiling and excited about what you are talking about then that is the thing you should do"
"Compare shoes.. if you are all wearing the same shoes then you are hanging out with the same people"
===
Speaker: Igor
Contact:
Topic: Yap Story - story of a start up
David vs gollaiath.
"to keep up, you will find yourself spending 8 hours to keep up, and 8 hours to surpress"
Koala bottle (using a cute descriptive name can help)
yoko onno apple in the art exhibit
===
Speaker: Todd Moy
Contact: @toddmoy
Topic: ..magic
"I can't do magic, I can help you see it"
user experience is the intercention between the user's mental model and interaction and the Designer's system.
-A  Beautiful Lie:
"fiiction can be more compelling than truth"
examples:
Turbo tax and the "analysing your taxis status loading bar"
Gmail "recall" feature delaying the email for a couple of seconds.
- Slight of hand
"work while they are distracted"
red paper heart (I don't remember why I wrote that)
===

Speaker: Doc Waller
Contact: :@docWaller
Topic: The power of words
I am having a hard time writing about this session. It was mind blowing and made me think about a lot of stuff. I found myself day dreaming and relating to every word.
"Transparency is sexy"
"Less ____ More Layman"

"Pinocchio had a rock bottom"
"Power words vs word with power"
"The Champ is here"
http://www.shopliftwindchimes.com/compliment.html
===

Speaker: Josh yolkert
Contact: @Skookum
Topic: Destruction
build -> fix -> integrate
"We are ____ shop" will die
===



I think I will stop here for now. I have 4 more pages of notes and it is getting really late
More info could be found here.
http://webafternoon.com
 

Razor Helpers

Razor helpers work just like functions in C# and JS. Create a function (and pass parameters to it if needed) and call it to draw the HTML.


Example:
@helper ShowName(string Name)
    {
          <p> hello @Name <p>
}

and then to use it

ShowName("Ammar")
ShowName("Mike")

The HTML will transplate to
<p> hello Ammar <p>
<p> hello Mike<p>

The output will show:
Hello Ammar
Hello Mike
Saturday, September 1, 2012

CSS quick cheat sheet/tutorial

I think it is about time I start building a cheat sheet for myself. Here is a CSS one to cover up all the basics.

How to use a CSS from another file:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

Elements and definition
SELECTOR { PROPERTY: VALUE; PROPERTY:VALUE;}
h1 { Color: BLUE; fontsize:12px;}

Comments:
/*This is how you comment*/

how to apply the style:
in the html line, use style="Color:Blue"

how to write a CSS
something
{
font-Size: 24px;
}

how write a CSS to apply it to what
. means  class selector for multiple elements  e.g. .RegisterElements. Or you can get p.RegisterElements

# means selects an id  e.g.  id="item"