Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Security
Imports System.Web.Mail
Public Class Functions
Inherits System.Web.UI.Page
'/** Class Functions
'/** Class written for: Krause
'/** Purpose: To define global functions to be used across the
'/** entire asp.net IMS application. Any functions that
'/** are reusable across various pages should be placed
'/** in this class.
'/** Usage:
'/** Dim f as New Functions
'/** f.FunctionName(Parameters...)
'/** Note: Please document any global or reusable function you implement
'/** so that other developers know how to use your code.
Public Function DefaultButton(ByRef Page As System.Web.UI.Page, ByRef objTextControl As TextBox, ByRef objDefaultButton As Button)
'/** Function: DefaultButton
'/** Purpose: Allows developers to set a default button on a page.
'/** Once the enter key is clicked inside a text box the
'/** default button is triggered and executed.
'/** Pre: Page, Valid Text Box, Button (all by reference)
'/** Post: Sets the default button
'/** Args: Page as System.Web.UI.Page, Textbox, Button
'/** Returns: N/A
Dim sScript As New System.Text.StringBuilder
sScript.Append("<SCRIPT language=""javascript"">" & vbCrLf)
sScript.Append("function fnTrapKD(btn){" & vbCrLf)
sScript.Append(" if (document.all){" & vbCrLf)
sScript.Append(" if (event.keyCode == 13)" & vbCrLf)
sScript.Append(" { " & vbCrLf)
sScript.Append(" event.returnValue=false;" & vbCrLf)
sScript.Append(" event.cancel = true;" & vbCrLf)
sScript.Append(" btn.click();" & vbCrLf)
sScript.Append(" } " & vbCrLf)
sScript.Append(" } " & vbCrLf)
sScript.Append("}" & vbCrLf)
sScript.Append("</SCRIPT>" & vbCrLf)
objTextControl.Attributes.Add("onkeydown", "fnTrapKD(document.all." & objDefaultButton.ID & ")")
Page.RegisterStartupScript("ForceDefaultToScript", sScript.ToString)
End Function
Function ValidatePassword(ByVal txtP As String, ByVal txtCP As String) As Boolean
'/** Function: ValidatePassword
'/** Purpose: To validate a password with a confirmation password
'/** Pre: Password / Confirmation Exist
'/** Post: Confirms password
'/** Returns: Boolean value
'function validates whether a password is valid or not
If (txtP = txtCP) Then
ValidatePassword = True 'good
Else
ValidatePassword = False 'bad
End If
End Function