http://www.blog.travisgneiting.com/wp-content/uploads/2012/01/Magazine-Ad-July-2011.pdf
Posts in category Uncategorized
CSS 3 and HTML 5 Button
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
/*Button*/
.button {
display: inline-block;
outline: none;
cursor: pointer;
text-align: center;
text-decoration: none;
font: 14px/100% Arial, Helvetica, sans-serif;
font-weight:bold;
padding: .5em 2em .55em;
text-shadow: 0 1px 1px rgba(0,0,0,.3);
-webkit-border-radius: .5em;
-moz-border-radius: .5em;
border-radius: .5em;
border-radius: 15px 15px 15px 15px;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.button:hover {
text-decoration: none;
}
.button:active {
position: relative;
top: 1px;
}
/*Gradient*/
.orange {
color: #fef4e9;
border: solid 1px #da7c0c;
background: #f78d1d;
background: -webkit-gradient(linear, left top, left bottom, from(#faa51a), to(#f47a20));
background: -moz-linear-gradient(top, #faa51a, #f47a20);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#faa51a', endColorstr='#f47a20');
}
.orange:hover {
background: #f47c20;
background: -webkit-gradient(linear, left top, left bottom, from(#f88e11), to(#f06015));
background: -moz-linear-gradient(top, #f88e11, #f06015);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f88e11', endColorstr='#f06015');
}
.orange:active {
color: #fcd3a5;
background: -webkit-gradient(linear, left top, left bottom, from(#f47a20), to(#faa51a));
background: -moz-linear-gradient(top, #f47a20, #faa51a);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f47a20', endColorstr='#faa51a');
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<a href="#" class="button orange">Orange</a>
</div>
</form>
</body>
</html>Custom Field RequiredFieldValidator Highlighting
There was a great post here by Yoann. B that provided a great example in C# for highlighting RequireFieldValidators: http://blog.sb2.fr/post/2008/12/12/Custom-TextBox-Required-Field-Validator.aspx
I expanded the code to allow for border widths, and converted the code to VB.
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Drawing
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Text
Namespace Validators
<DefaultProperty("Text")> _
<ToolboxData("<{0}:TextBoxRequiredFieldValidator runat=server></{0}:TextBoxRequiredFieldValidator>")> _
Public Class TextBoxRequiredFieldValidator
Inherits RequiredFieldValidator
#Region "Public Properties"
Public Property ErrorBackgroundColor() As Color
Get
If ViewState("ErrorBackgroundColor") Is Nothing Then
Return Color.LightGray
Else
Return DirectCast(ViewState("ErrorBackgroundColor"), Color)
End If
End Get
Set(ByVal value As Color)
ViewState("ErrorBackgroundColor") = value
End Set
End Property
Public Property ErrorBorderColor() As Color
Get
If ViewState("ErrorBorderColor") Is Nothing Then
Return Color.Red
Else
Return DirectCast(ViewState("ErrorBorderColor"), Color)
End If
End Get
Set(ByVal value As Color)
ViewState("ErrorBorderColor") = value
End Set
End Property
Public Property ErrorBorderWidth() As Unit
Get
If ViewState("ErrorBorderWidth") Is Nothing Then
Return Unit.Pixel(1)
Else
Return DirectCast(ViewState("ErrorBorderWidth"), Unit)
End If
End Get
Set(ByVal value As Unit)
ViewState("ErrorBorderWidth") = value
End Set
End Property
#End Region
#Region "Private Properties"
Private Property OriginalBackgroundColor() As Color
Get
If ViewState("OriginalBackgroundColor") Is Nothing Then
Return Color.LightGray
Else
Return DirectCast(ViewState("OriginalBackgroundColor"), Color)
End If
End Get
Set(ByVal value As Color)
ViewState("OriginalBackgroundColor") = value
End Set
End Property
Private Property OriginalBorderColor() As Color
Get
If ViewState("OriginalBorderColor") Is Nothing Then
Return Color.Red
Else
Return DirectCast(ViewState("OriginalBorderColor"), Color)
End If
End Get
Set(ByVal value As Color)
ViewState("OriginalBorderColor") = value
End Set
End Property
Private Property TextBoxToValidate() As TextBox
Get
Return m_TextBoxToValidate
End Get
Set(ByVal value As TextBox)
m_TextBoxToValidate = value
End Set
End Property
Private m_TextBoxToValidate As TextBox
#End Region
#Region "Protected Overrides Methods"
Protected Overrides Sub OnInit(ByVal e As EventArgs)
MyBase.OnInit(e)
Dim txt As TextBox = TryCast(Me.FindControl(MyBase.ControlToValidate), TextBox)
If txt IsNot Nothing Then
TextBoxToValidate = txt
OriginalBackgroundColor = TextBoxToValidate.BackColor
OriginalBorderColor = TextBoxToValidate.BorderColor
End If
End Sub
Protected Overrides Function EvaluateIsValid() As Boolean
Dim bIsValid As [Boolean] = False
Dim Value As [String] = MyBase.GetControlValidationValue(MyBase.ControlToValidate)
If [String].IsNullOrEmpty(Value) Then
If TextBoxToValidate IsNot Nothing Then
TextBoxToValidate.BackColor = ErrorBackgroundColor
TextBoxToValidate.BorderColor = ErrorBorderColor
bIsValid = False
End If
Else
If TextBoxToValidate IsNot Nothing Then
TextBoxToValidate.BackColor = OriginalBackgroundColor
TextBoxToValidate.BorderColor = OriginalBorderColor
bIsValid = True
End If
End If
Return bIsValid
End Function
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
MyBase.OnPreRender(e)
If Page.ClientScript.IsClientScriptBlockRegistered("ValidationScript") Then
Return
End If
Dim ControlToValidateClientId As [String] = MyBase.GetControlRenderID(MyBase.ControlToValidate)
Dim Script As New StringBuilder()
Script.Append("<script language=""javascript"">")
Script.Append("function RequiredFieldValidatorEvaluateIsValid(val) {")
Script.Append(" var value = ValidatorGetValue(val.controltovalidate);")
Script.Append("if (value == '') {")
Script.Append("document.getElementById(val.controltovalidate).style.backgroundColor = '$$BGCOLOR$$';")
Script.Replace("$$BGCOLOR$$", ColorTranslator.ToHtml(ErrorBackgroundColor))
Script.Append("document.getElementById(val.controltovalidate).style.borderColor = '$$BRCOLOR$$';")
Script.Replace("$$BRCOLOR$$", ColorTranslator.ToHtml(ErrorBorderColor))
Script.Append("document.getElementById(val.controltovalidate).style.borderWidth = '$$BRWIDTH$$';")
Script.Replace("$$BRWIDTH$$", ErrorBorderWidth.ToString)
Script.Append("return false; }")
Script.Append("else {")
Script.Append("document.getElementById(val.controltovalidate).style.backgroundColor = '$$ORIG_BGCOLOR$$';")
Script.Replace("$$ORIG_BGCOLOR$$", ColorTranslator.ToHtml(OriginalBackgroundColor))
Script.Append("document.getElementById(val.controltovalidate).style.borderColor = '$$ORIG_BRCOLOR$$';")
Script.Replace("$$ORIG_BRCOLOR$$", ColorTranslator.ToHtml(OriginalBorderColor))
Script.Append("return true;} }")
Script.Append("</script>")
Page.ClientScript.RegisterClientScriptBlock(Me.[GetType](), "ValidationScript", Script.ToString())
End Sub
#End Region
End Class
End NamespaceHere is the usage of the Overload.
You must register the custom control on the page, include the “Assembly” attribute if from outside your project.
<%@ Register TagPrefix="MyCtrl" Namespace="Validators" %>The control is used just like the regular required field validator.
<myctrl:textboxrequiredfieldvalidator ID="valid1" runat="server" ControlToValidate="TextBox1" ErrorBackgroundColor="Red" ErrorBorderColor="Red" ErrorBorderWidth="2" SetFocusOnError="true"></myctrl:textboxrequiredfieldvalidator>Status Codes and MIME Types
text Textual information. Subtypes include plain, html, and xml.
image Image data. Subtypes are defined for two widely used image formats,
jpeg and gif, and other subtypes exist as well.
audio Audio data. Requires an audio output device (such as a speaker or headphones)
for the contents to be heard. An initial subtype, basic, is defined
for this type.
video Video data. The subtype mpeg is often used. Typically, videos are not
transferred directly, but are read from an embedded object, such as a
JavaScript or Adobe Flash object.
application Any binary data. The subtype octet-stream is typically used.
Process vs. Thread
Using Processes and Threads provide a way for paralleling work on a computer. Processes are independent execution units that contain their own state and address spaces. Basically an instance or execution of a program. And they can only communicate with other processes via interprocess communication. The division of processes should be done during the design phase.
Threading should not affect an architecture of an application. A single process can contain multiple threads. All threads share the same state and same space in memory. They can communicate with each other because they use the same variables.
Threads power comes from their ease of creation, while process creation is not so straightforward.
Truncate Table with Delete and Reseed
Delete From [tableName]
DBCC CHECKIDENT ([tableName], reseed, 0)
.NET Framework 4.0 Statistics … This is interesting
I’ve often found it’s hard to know all that the framework has to offer. I’m left wondering I wonder where I can look to find somthing like that. I’ve also found it’s hard to get a complete 10,000 foot view of the entire framework. I think I know some reasons why now… It’s ginormious. Check out the stats from Scott Dorman’s blog.
http://geekswithblogs.net/sdorman/archive/2010/07/10/interesting-.net-framework-4-statistics.aspx
There were a total of 44,346 types (loaded from 130 assemblies), with 33,152 classes, 2,398 interfaces, 4,828 enums, and 8,796 value types. The complete breakdown is shown below.

Of the 33,152 classes, 564 of them are exceptions. There are 428 public and 136 non-public exceptions. The complete breakdown is shown below.
ASP.NET Podcast
Here is a list of a few of my favorite ASP.NET and other podcast.
Exam 70-515: TS: Web Applications Development with Microsoft .NET Framework 4 prep
Exam 70-515:
TS: Web Applications Development with Microsoft .NET Framework 4
I hope I’m not the only one that was disappointed to see that the release for the study guide for the 70-515 Web App Development has been pushed back. I believe on Amazon the date is as late as December 30th! A couple months ago the release was scheduled for November 15th. I recently finished my Masters Degree, and my brain is turning to mush, and this was my next challenge.
Well, here are a few things I’ll be reviewing until the book is released, hope they help someone else too.
From Microsofts Learning page, the exam is explain as follows.
About this Exam
Audience Profile
- Accessing data by using Microsoft ADO.NET and LINQ
- Creating and consuming Web and Windows Communication Foundation (WCF) services
- State management
- ASP.NET configuration
- Debugging and deployment
- Application and page life-cycle management
- Security aspects such as authentication and authorization
- Client-side scripting languages
- Internet Information Server (IIS)
- ASP.NET MVC
Credit Toward Certification
When you pass Exam 70-515: TS: Web Applications Development with Microsoft .NET Framework 4, you complete the requirements for the following certification(s):
- MCTS: .NET Framework 4, Web Applications
Exam 70-515: TS: Web Applications Development with Microsoft .NET Framework 4: counts as credit toward the following certification(s):
- MCPD: Web Developer 4
Skills Being Measured
This exam measures your ability to accomplish the technical tasks listed below.The percentages indicate the relative weight of each major topic area on the exam.
Developing Web Forms Pages (19%)
- Configure Web Forms pages.
This objective may include but is not limited to: page directives such as ViewState, request validation, event validation, MasterPageFile; ClientIDMode; using web.config; setting the html doctype
This objective does not include: referencing a master page; adding a title to a Web form
- Implement master pages and themes.
This objective may include but is not limited to: creating and applying themes; adding multiple content placeholders; nested master pages; control skins; passing messages between master pages; switching between themes at runtime; loading themes at run time; applying a validation schema
This objective does not include: creating a master page; basic content pages
- Implement globalization.
This objective may include but is not limited to: resource files, browser files, CurrentCulture, currentUICulture, ASP:Localize - Handle page life cycle events.
This objective may include but is not limited to: IsPostback, IsValid, dynamically creating controls, control availability within the page life cycle, accessing control values on postback, overriding page events - Implement caching.
This objective may include but is not limited to: data caching; page output caching; control output caching; cache dependencies; setting cache lifetimes; substitution control
This objective does not include: distributed caching (Velocity) - Manage state.
This objective may include but is not limited to: server-side technologies, for example, session and application; client-side technologies, for example, cookies and ViewState; configuring session state (in proc, state server, Microsoft SQL Server; cookieless); session state compression; persisting data by using ViewState; compressing ViewState; moving ViewState
Developing and Using Web Forms Controls (18%)
- Validate user input.
This objective may include but is not limited to: client side, server side, and via AJAX; custom validation controls; regex validation; validation groups; datatype check; jQuery validation
This objective does not include: RangeValidator and RequiredValidator
- Create page layout.
This objective may include but is not limited to: AssociatedControlID; Web parts; navigation controls; FileUpload controls
This objective does not include: label; placeholder, panel controls; CSS, HTML, referencing CSS files, inlining
- Implement user controls.
This objective may include but is not limited to: registering a control; adding a user control; referencing a user control; dynamically loading a user control; custom event; custom properties; setting toolbox visibility - Implement server controls.
This objective may include but is not limited to: composite controls, INamingContainer, adding a server control to the toolbox, global assembly cache, creating a custom control event, globally registering from web.config; TypeConverters
This objective does not include: postback data handler, custom databound controls, templated control
- Manipulate user interface controls from code-behind.
This objective may include but is not limited to: HTML encoding to avoid cross-site scripting, navigating through and manipulating the control hierarchy; FindControl; controlRenderingCompatibilityVersion; URL encoding; RenderOuterTable
This objective does not include: Visibility, Text, Enabled properties
Implementing Client-Side Scripting and AJAX (16%)
- Add dynamic features to a page by using JavaScript.
This objective may include but is not limited to: referencing c
lient ID; Script Manager; Script combining; Page.clientscript.registerclientscriptblock; Page.clientscript.registerclientscriptinclude; sys.require (scriptloader)
This objective does not include: interacting with the server; referencing JavaScript files; inlining JavaScript - Alter a page dynamically by manipulating the DOM.
This objective may include but is not limited to: using jQuery, adding, modifying, or removing page elements, adding effects, jQuery selectors
This objective does not include: AJAX
- Handle JavaScript events.
This objective may include but is not limited to: DOM events, custom events, handling events by using jQuery - Implement ASP.NET AJAX.
This objective may include but is not limited to: client-side templating, creating a script service, extenders (ASP.NET AJAX Control Toolkit), interacting with the server, Microsoft AJAX Client Library, custom extenders; multiple update panels; triggers; UpdatePanel.UpdateMode; Timer
This objective does not include: basic update panel and progress
- Implement AJAX by using jQuery.
This objective may include but is not limited to: $.get, $.post, $.getJSON, $.ajax, xml, html, JavaScript Object Notation (JSON), handling return types
This objective does not include: creating a service
Configuring and Extending a Web Application (15%)
- Configure authentication and authorization.
This objective may include but is not limited to: using membership, using login controls, roles, location element, protecting an area of a site or a page
This objective does not include: Windows Live; Microsoft Passport; Windows and Forms authentication
- Configure providers.
This objective may include but is not limited to: role, membership, personalization, aspnet_regsql.exe
This objective does not include: creating custom providers
- Create and configure HttpHandlers and HttpModules.
This objective may include but is not limited to: generic handlers, asynchronous handlers, setting MIME types and other content headers, wiring modules to application events - Configure initialization and error handling.
This objective may include but is not limited to: handling Application_Start, Session_Start, and Application_BeginRequest in global.asax, capturing unhandled exceptions, custom error section of web.config, redirecting to an error page; try and catch; creating custom exceptions - Reference and configure ASMX and WCF services.
This objective may include but is not limited to: adding service reference, adding Web reference, changing endpoints, wsdl.exe, svcutil.exe; updating service URL; shared WCF contracts assembly
This objective does not include: creating WCF and ASMX services
- Configure projects and solutions, and reference assemblies.
This objective may include but is not limited to: local assemblies, shared assemblies (global assembly cache), Web application projects, solutions, settings file, configuring a Web application by using web.config or multiple .config files; assemblyinfo - Debug a Web application.
This objective may include but is not limited to: remote, local, JavaScript debugging, attaching to process, logging and tracing, using local IIS, aspnet_regiis.exe - Deploy a Web application.
This objective may include but is not limited to: pre-compilation, publishing methods (e.g.,
MSDeploy, xcopy, and FTP), deploying an MVC applicationThis objective does not include: application pools, IIS configuration
Displaying and Manipulating Data (19%)
- Implement data-bound controls.
This objective may include but is not limited to: advanced customization of DataList, Repeater, ListView, FormsView, DetailsView, TreeView, DataPager, Chart, GridView
This objective does not include: working in Design mode
- Implement DataSource controls.
This objective may include but is not limited to: ObjectDataSource, LinqDataSource, XmlDataSource, SqlDataSource, QueryExtender, EntityDataSource
This objective does not include: AccessDataSource, SiteMapDataSource
- Query and manipulate data by using LINQ.
This objective may include but is not limited to: transforming data by using LINQ to create XML or JSON, LINQ to SQL, LINQ to Entities, LINQ to objects, managing DataContext lifetime
This objective does not include: basic LINQ to SQL
-
Create and consume a data service.This objective may include but is not limited to: WCF, Web service; server to server calls; JSON serialization, XML serialization
This objective does not include: client side, ADO.NET Data Services
- Create and configure a Dynamic Data project.
This objective may include but is not limited to: dynamic data controls, custom field templates; connecting to DataContext and ObjectContext
Developing a Web Application by Using ASP.NET MVC 2 (13%)
- Create custom routes.
This objective may include but is not limited to: route constraints, route defaults, ignore routes, custom route parameters - Create controllers and actions.
This objective may include but is not limited to: Visual Studio support for right-click context menus; action filters (including Authorize, AcceptVerbs, and custom) and model binders; ActionResult sub-classes - Structure an ASP.NET MVC application.
This objective may include but is not limited to: single project areas (for example, route registration, Visual Studio tooling, and inter-area links); organizing controllers into areas; shared views; content files and folders - Create and customize views.
This objective may include but is not limited to: built-in and custom HTML helpers (for example, HTML.RenderAction and HTML.RenderPartial), strongly typed views, static page checking, templated input helpers, ViewMasterPage, ViewUserControl
This objective does not include: Microsoft.Web.Mvc Futures assembly
Variable Scope
Variable Scope
The Scope or Accessibility of a variable depends on where it can be called in an application, and what the lifetime in memory the variable has. This also determines what context the method can be called. The following are defining terms for scope variables.
Scope Terms
Public: Anywhere in or outside of a project
Private: Only in the block where defined
Protected: Can be used in the class where defined. Can also be used within any inherited classes.
Friend: Can only be accessed in code in the same project or assembly
ProtectedFriend: Combination of Protected and Friend
Scope Rules
There are four levels that variables can be declared in an application.
1.Block: i.e. within an if statement, the variable lifetime ends at the end of the block
2.Procedure: i.e. within a method, outside of an if statement
3.Class: i.e. within a class the lifetime ends when the object is cleaned by the garbage collector
4.Project: i.e. Public variables within module statements, lifetime is until the program ends
Procedure Modifiers
Public: Can be called from anywhere in a project
Private: Can only be called within the class it is declared
Protected: Can only be in the same class from the same class or inherited classes
Friend: Can be called from any code in the same project or assembly
ProtectedFriend: Can be called from in its defined, derived, or procedures in the same project/assembly
Static Variables
Shadowing
Reference: http://msdn.microsoft.com/en-us/library/ms973875.aspx



