The Blog of Travis Gneiting
  • Home
KEEP IN TOUCH

Posts by Travis

Notes on SQLMembership Provider using the MembershipProvider Class

Nov15
2011
Leave a Comment Written by Travis

1. Set the tag to use “forms” in the config
2. use the reg_sql to generate the SQL tables for use with SQLMembership Provider.
3. Add 4. Can use membership.createuser(“UN”,”PW”,”Email”) to create user.
5. Methods include:Createuser, ValidateUser, DeleteUser, FinduserByName,finduserByEmail,GenPassword
6.Options to capture other user info with ProfileSystem, and defining provider properties in webconfig. Or simply adding additional tables.

Posted in Membership

Table to Excel XLS code

Nov15
2011
Leave a Comment Written by Travis

Dim StringWriter1 As IO.StringWriter
Dim StringBuilder1 As StringBuilder = New StringBuilder
StringWriter1 = New IO.StringWriter(StringBuilder1)
Dim TextWriter1 As HtmlTextWriter = New HtmlTextWriter(oStringWriter)
label.RenderControl(oTextWriter)
Response.Clear()
Response.ClearHeaders()
Response.ContentType = “application/vnd.xls”
Response.AddHeader(“Content-Disposition”, “attachment;filename=WLMS-exlfile.xls”)
Response.Write(StringWriter1.ToString())
Response.Flush()
Response.End()

Posted in ASP.NET

New Website Checklist

Nov14
2011
Leave a Comment Written by Travis

Checklist
· Twitter Account
· Facebook Business Page Account
· Google Business
· Linked In Business Page
· Human.txt
· Robot.txt
· Emails
· News Letters
· Privacy Policy
· Contact Us
· Sitemap
· Blog
· Forum
Website Tools
· Google Webmaster Tools
· Google Alerts
· Google Keyword Tools
· addThis
· Google Page Speed
· Mozrank (Metrics)
· Google Analytics (Metrics)
· Spotify
· Intense Debate
· Feedburner
Guidelines
· Schema.org
Features
· OpenAuth
WP Specific
· Forum
· Akismet
· Allow PHP
SEO
· Linkbuilding

Posted in Architecture - Tagged New Website Checklist

Google Blueprint CSS Love

Nov01
2011
Written by Travis

http://blueflavor.com/blog/2007/oct/24/blueprint-css-101/

Posted in CSS - Tagged Blueprint, CSS

Microsoft Project Code Name Velocity

Nov01
2011
Written by Travis

Microsoft Velocity provides distributed in-memory web application caching. This provides highly scalable, high-performance application caching. “Velocity Caching” can be used to cache any Common Language Runtime (CLR is the Virtual Machine of Microsoft’s .NET initiative) through simple API’s. From a general standpoint, Velocity was created with the goal of providing performance, scalability and availability.

The main application for providing scalable, available, high-performance applications using Velocity is by fusing the memory between multiple computers to give a single/unified cache view for the application to employ.The application can they store any CLR object that is serializable.

http://blogs.msdn.com/velocity/

Posted in Caching - Tagged ASP.NET, Velocity

Microsoft and PHP Patterns and Practices

Nov01
2011
Written by Travis

http://msdn.microsoft.com/en-us/practices/default.aspx

According to Microsoft P&P (Patterns and Practices) were created to meet the demands of architects and application developers.By following proven patterns and practices it is suggested that more sound applications will be the result. Included in P&P

  • How to design
  • Develop
  • Deploy
  • Operate architecturally sound applications on a Microsoft platform.

P&P for Web Applications

http://msdn.microsoft.com/en-us/practices/bb969054.aspx#web_apps

PHP Patterns and Practices

http://www.phppatterns.com/docs/start

Posted in Architecture

Calling WebService from Javascript Error

Aug26
2011
Leave a Comment Written by Travis

I recently wasn getting the following error when trying to call a webservice from javascript.

“Request format is unrecognized for URL unexpectedly ending in ‘/Search’.”

I was able to invoke the web services from the test page offered by visual studio, but accessing it outside the invoke method on the test page would not work.

By default, webservices protocols are not added to the webconfig. To access normal get/post services you will need to add the following in the <system.web> node.

Source code   
<webServices>
<protocols>
<add name="HttpPost"/>
<add name="HttpGet"/>
</protocols>
</webServices>

 

Posted in WebService

CSS 3 and HTML 5 Button

Jul29
2011
Leave a Comment Written by Travis
Source code   
<%@ 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>
Posted in Uncategorized

Setting the SelectedValue of RadioButtonList & DropDownList in GridView EditItemTemplate

Jun19
2011
Leave a Comment Written by Travis

Here is a trick one, because IntelliSense doesn’t bring up the “SelectedValue” property for a RadioButtonList, or a DropDownList in an EditItemTemplate for GridViews you may forget that “SelectedValue” is an actual property of these controls.

Here is how you can set the selected value of a RadioButtonList inside an EditItemTemplate

Source code   
<asp:TemplateField HeaderText="Payment">
<ItemTemplate>
    <asp:Label ID="lablePayment" runat="server" Text='<%#Eval("PayName")%>' />
</ItemTemplate>
<EditItemTemplate>
  <asp:RadioButtonList Runat = "server" ID="rblPaymentType" SelectedValue='<%#Eval("PayTypeID")%>'>
    <asp:ListItem Text="Check" Value="1"></asp:ListItem>
    <asp:ListItem Text="Credit Card" Value="2"></asp:ListItem>
  </asp:RadioButtonList>
</EditItemTemplate>
</asp:TemplateField>
Posted in ASP.NET

Custom Field RequiredFieldValidator Highlighting

May25
2011
Leave a Comment Written by Travis

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
« Older 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

  • 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