The Blog of Travis Gneiting
  • Home
KEEP IN TOUCH

Custom Field RequiredFieldValidator Highlighting

May25
2011
Leave a Comment Written by admin

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.

Source code   
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 Namespace

Here is the usage of the Overload.

You must register the custom control on the page, include the “Assembly” attribute if from outside your project.

Source code   
<%@ Register TagPrefix="MyCtrl" Namespace="Validators" %>

The control is used just like the regular required field validator.

Source code   
<myctrl:textboxrequiredfieldvalidator ID="valid1" runat="server" ControlToValidate="TextBox1" ErrorBackgroundColor="Red" ErrorBorderColor="Red" ErrorBorderWidth="2" SetFocusOnError="true"></myctrl:textboxrequiredfieldvalidator>
Posted in Uncategorized

Quick notes on SEO WebCast

May16
2011
Leave a Comment Written by admin

Alex Gould – High Search Engine Rankings

2/24/2011-New Panda Google Release “We lanched a pretty big algorithmic change 12%”

1. Be the athority in your niche field. (Start Social Network Niche, be involved in groups)

2.When writing comment on the big names in your field, built rapar with them.

a.Add quality comments to pages and include Links

3.Wikipedia Links are very valuable, try to get them.

4.Bookmarking sites like Delicious, Faves.com, furl.com, Stumbleupon.com

a. Bookmark ever article and page on your website, also bookmark pages that link to your site.

5.Social Poster (Tool)
5.Local Directories

a.Classified Ads, usfreeads,craigslist,epage

b.Universitys, Chamber of Commerece, niche directories

5.Yahoo site explorer

5.SEO Link Vine

5.Statbrain, websiteoutlook, builtwith, snapshot, quantcast, cubestat,siteadvisor, robtex.com, zimbio, searchanalytics.complete.com

6.Videos

a.Create videos with targeted keywords

b.Tag videos with links to website, and call to action to visit website

c.Tubemogal, Animoto, cantatia (Video tools)

7.Digg, Redit, DZone

a.di66.net (Youtube Content Source) Digg your youtube videos (most diggs are videos)

8.Reviews

a.ePenions, osoyou.com, q&a sites (yahoo answers, eHow comments)

b.Try switching proxy to add comments from different IP

9.Content Sharing

a.Squidoo, Hubpage

10.Artical Submission

a.ishare, ezine articles, go articles, syndicate your articals, convert articles to pdf/slide shows and submit, spin content 50%.

11.Track what you do

a.Use excel file to track all links, comments posted, RSS Feeds, Social Bookmarks

12.Article Directories, syndicate

13.Circular SEO, links to self and others back to self.
“The Right Way to … Most People Mess this up big time.”

“Away to instantly… that works everytime.”

“News Flash: Most people don’t realize this”

“A simple… That doubles your …”

“The 4 things you must never do when…”

“I was talking with… and “s

————————————————————————————

Mark Joiner – Mindcontrolnow.com Use Human psychological factor.

1.How to create video from post.
2.We obey the athority (Burton). Shocks sent that could kill someone.

3.How to use obedience to athority as an affiliate. Establish yourself as an athority in the area, and give a recomendation. The recommendation is higher that just some random person saying they like something. Having an eBook downloaded 1M times established as an athority. Sneeky ways to establish as an athrotiy.  Go do something first, then get someone else to say how good it was.

4.Launch Campain: Buy Copies of their own books (Best Sellers). Dosen’t happen just by chance, their is something deliberatly they did.

5.Books establish you as an athroity.

a.Offer Teaser Material (Target (free product to same market of people who would buy), Tie in (free item to what you will be selling), Connect (Contact info to who collected the freebie))

b.Get a team of affilates to contribute in pre launch.

c.Get other people to say good thing about you.

d.Foot in the door (commit to small thing before submitt to big thing)

e.Feel like they owe you something

f.Demonstrate you are expert

g. Use Graphs and Statistics or Studies

f.”I’m going to tell you who the pitcher for the podreys, but first I’m going to tell you a story”

g. Present Testimonial from other companies first. Then ask for their testimonal as with Name and URL.

6.Your ad has to be done, and used.

7. Powerfull way to sell something as an affiliate, Tell a personal story, depending on the level of athority.

8.Zagarnek effect (headline leaves you wanting more)

Heavy & Deadly Ground:

————————————————-

Posted in SEO

Software Development Process – Using Object Oriented Analysis and Design through Iterative Development

Feb23
2011
Leave a Comment Written by admin

There are some general good practices to follow when building a new software application. Below provides a good outline of steps when following an Object-Oriented methodolgy when performing the Analysis and Design during Iterative development.

Following the Unified Process (UP)

  1. Inception (Artifacts (any work product) are Optional)
    A short phase to develop and analze the vision/business case, Use-Case (Some) & Models, Supplementary Specification, Glossary, Risk Management, Iteration Planning,  Proof of concepts, Scope, Estimations, Development Case.
  2. Elaboration Phase (Multi-iteration)
    Most requirements analysis should occure in the Elaboration phase. Refining vision, core architecture, resolution of risk, identify most requirements & Use Case, realistic estimates, Domain Models, SSD, Interaction Diagram, Class Diagram, TDD,
  3. Construction
    Full iterative implementation, preperation for deployment
  4. Transition
    Testing and Deployment

Following the Unified Process Disiplines

  1. Business Modeling
    Visual and noteworthy concepts in the application domain.
  2. Requirements
    Use-Case and Models,Specification artifacts showing functional and non-functional requirements.
  3. Design
    Design Model Artifacts, for architectual objects, UI
  4. Implementation
  5. Test
  6. Deployment
  7. Configuration & Change Management
  8. Project Management
    Agile, Scrum
  9. Environment
  10. Business Modeling
    Agile Modeling
  11. Requirements
  12. Design
    Agile Modeling
  13. Implementation
    Test-Driven Develoment TDD, Continuous integration, Coding Standards
Posted in Architecture

Status Codes and MIME Types

Feb17
2011
Leave a Comment Written by admin

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.

Posted in Uncategorized - Tagged IIS, MIME, Status Codes

Distributed Authoring and Versioning (DAV)

Feb16
2011
Leave a Comment Written by admin

Distributed Authoring and Versioning is a set of extensions to HTTP/1.1.  This open standard provides the ability to lock and unlock files and also assign versions to these files.

Distributed Authoring and Versioning (DAV) is built on HTTP/1.1, and can stand alone. A powerful capability of DAV is the ability to query the server for file names, time stamps, sizes, serverside copy and move.

Posted in HTTP - Tagged HTTP

Compiled Language vs. Interpreted Language

Feb07
2011
Leave a Comment Written by admin

Programming languages generally fall into one of the following categories, Compiled Language or Interpreted Language. Compiled Languages are reduced to a set of machine instructions before being saved as an executable file. In general, a compiled program will execute faster thatn an interpreted program because the Interpreted program must be reduced to machine language at runtime.

Interpreted languages that code is saved in the same format and developed in. Interpreted languages offer more flexability like modifying themselves by adding or changing functions at runtime. Development time can also be reduced with interpreted languages, because the application dose not need to be compiled before each test.

In theory any language can be compiled or interpreted. The Microsoft .NET language is compiled to Common Intermediate Language (CIL) which is compiled into native machine code.

Posted in Software Engineering

Conditional Hyperlink in template

Jan11
2011
Leave a Comment Written by admin

<%

#IIf((Eval(“id”) Is System.DBNull.Value), Eval(“Last”) & “, “ & Eval(“First”), “<a href=” ../default.aspx?id=” & Eval(“id”) & “>” & Eval(“Last”) & “, “ & Eval(“First”) & “</a>”)%>

Posted in ASP.NET

Process vs. Thread

Nov30
2010
Leave a Comment Written by admin

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.

Posted in Uncategorized

Hotmail sending email to Contacts with a link

Nov09
2010
3 Comments Written by admin

Recently I have noticed a lot of links coming in and out of hotmail accounts. The attack seems to send links our to 10 or so of the users contacts at a time. all the links point to .au websites. The email only contains a link something similar to http: // patiodetango . com.au/to.html . However I noticed with these email was included a small amount of byte data when viewing the email on my android phone. We are seening a lot of these emails in Utah, United states of america USA. I get a few of these emails a day from friends, is anyone else seeing this behavior? Please comment and let me know.

[Update]

After logging into my Hotmail account today I noticed that MSN Hotmail must be onto something now too. There is a message at the top of my inbox that now states “A real message vs. a scam?” . “You know it’s a real message when it has the trusted sender icon. That means Hotmail has checked to make sure it’s from a legitimate source, instead of a harmful scam. Check it out”

The link takes you to a page in Windows live MSN that talks about Safety filters, trusted sender icons, safe email.

Here is the quoted text:

”

Windows Live Hotmail helps you keep an eye out for potentially unsafe email messages, so you can stay safer online. With safety features like filters that block viruses and notifications that help you identify messages sent by people you don’t know, Hotmail can help protect you and your computer.

Safety filters

Robust antivirus filters scan attachments and downloads and help block harmful content like malware and phishing email messages.

Look for trusted sender icon in messages

The trusted sender icon lets you know that a message is from a legitimate sender that Hotmail has verified, like your bank or the Windows Live team.

Mark email addresses you know as safe

If you trust the person or website that sent you a message, you can mark them as safe. This sends any messages from them straight to your inbox.

Watch for yellow and red safety bars

A yellow safety bar means that a message contains blocked attachments, pictures, or links to websites. Check the sender of the message and make sure that you trust them before downloading any attachments or pictures or clicking any links.

A red safety bar means that the message you received contains something that might be unsafe and has been blocked by Hotmail. It’s recommended you don’t open these types of email messages and delete them from your inbox.”

If you have an MSN or hotmail account you can view the message here. http://explore.live.com/windows-live-hotmail-safer-inbox-tips-using

Posted in Websites - Tagged attack, hacked, Hotmail, spoof

Truncate Table with Delete and Reseed

Nov08
2010
Leave a Comment Written by admin

 

Delete From [tableName] 

DBCC CHECKIDENT ([tableName], reseed, 0)

Posted in Uncategorized
« Older Entries Newer Entries »

Programming

  • ASP.NET
  • MSDN
  • Visual Studio Offical Website
  • www.w3.org

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Welcome to My Programming Blog

This is my brain dump. I use it to post thing I may use again, interesting things I have run into and programming helps.

Tags

.net Agile Software Development Engineering ASP.NET attack Beginner Blueprint CSS Database Deployment DevExpress Framework Functional hacked Hotmail How to test software HTTP IIS Javascript JQuery MIME New Website Checklist PHP querystring Software Testing Specification spoof Status Codes Testing Trace Debug ASP.NET Tutorial Velocity webmethod Website Testing Zend

Blog Archive

  • January 2012
  • November 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • February 2011
  • January 2011
  • November 2010
  • October 2010
  • August 2010
  • July 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • February 2009
  • January 2009
  • November 2008
  • September 2008
  • August 2008
  • July 2008
  • April 2008

EvoLve theme by Theme4Press  •  Powered by WordPress The Blog of Travis Gneiting