Notes on SQLMembership Provider using the MembershipProvider Class

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.

 

[tester]

Table to Excel XLS code

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()

New Website Checklist

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

Microsoft Project Code Name Velocity

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/

Microsoft and PHP Patterns and Practices

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

Calling WebService from Javascript Error

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.

[codesyntax lang=”xml”]

<webServices>
<protocols>
<add name=”HttpPost”/>
<add name=”HttpGet”/>
</protocols>
</webServices>

[/codesyntax]

 

CSS 3 and HTML 5 Button

[codesyntax lang=”vbnet”]

<%@ 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>

[/codesyntax]

Setting the SelectedValue of RadioButtonList & DropDownList in GridView EditItemTemplate

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

[codesyntax lang=”html4strict”]

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

[/codesyntax]

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.

[codesyntax lang=”vbnet”]

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

[/codesyntax]

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.

[codesyntax lang=”vbnet”]

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

[/codesyntax]

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

[codesyntax lang=”vbnet”]

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

[/codesyntax]