Home
About
Contact
Categories
Classic ASP (32 - Entries)
CSS (1 - Entry)
JavaScript (5 - Entries)
Databases (30 - Entries)
ASP.NET (26 - Entries)
Delphi (6 - Entries)
Windows Server Core (13 - Entries)
VMWare (1 - Entry)
Code Editing Tools (2 - Entries)
Linux (4 - Entries)
Dell Servers (15 - Entries)
Design and Editing Software (1 - Entry)
Blog Entries
2025 (3 - Entries)
Bug Reports
(Bugs Fixed
CFFCS Coding Source
Please report any errors to the [
Contact
] page. Thank you.
Classic ASP (32)
CSS (1)
JavaScript (5)
Databases (30)
ASP.NET (26)
Delphi (6)
Windows Server Core (13)
VMWare (1)
Code Editing Tools (2)
Linux (4)
Dell Servers (15)
Design and Editing Software (1)
Tools
Format Your SQL Script
Minify your CSS
Resources
[View The Source Code For This Project]
ASP.NET
VB.NET
ASP.NET (VB Version) check if Zip Code exists. If not, show a message
Live Editing Disabled for Server-Side Example
HTML
Load.aspx
<%@ Page Language="VB" ValidateRequest="False" AutoEventWireup="false" CodeFile="Load.aspx.vb" Inherits="Load" %>
Zip Code:
City =
State =
County =
ASP.NET
web.config
database.config
Load.aspx.vb
Imports System.Data.SqlClient Partial Class Load Inherits System.Web.UI.Page Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load ShowZip.Visible = False End Sub Private Function ProtectXSS(ByVal SqlString As String) As String SqlString = Replace(SqlString, "'", "'") ' replace single Quotes with Double Quotes SqlString = Replace(SqlString, ">", ">") ' replace > with > SqlString = Replace(SqlString, "<", "<") ' replace < with < SqlString = Replace(SqlString, "(", "(") ' replace ( with ( SqlString = Replace(SqlString, ")", ")") ' replace ) with ) SqlString = Trim(SqlString) ProtectXSS = SqlString End Function Protected Sub Sub_Click(sender As Object, e As EventArgs) Handles
.Click Dim LessonCon As New SqlConnection Dim LessonCMD As SqlCommand = Nothing Dim ZC As String = ProtectXSS(Zip.Text) 'Response.Write(ZC) 'Response.End() LessonCon = New SqlConnection(ConfigurationManager.ConnectionStrings("Virtual-Learning").ConnectionString) LessonCon.Open() If Not IsNumeric(ZC) Then Response.Write(ZC & "Not a valid number, please enter a Zip Code.") Else Dim getZip As New SqlCommand("select Zip, City, State, County from ZipTable where Zip=@Zip", LessonCon) getZip.Parameters.Add(New SqlParameter("@Zip", ZC)) Dim rsZip As SqlDataReader rsZip = getZip.ExecuteReader() If rsZip.Read() Then ShowZip.Visible = True Zipcode.Text = rsZip("Zip") City.Text = rsZip("City") State.Text = rsZip("State") County.Text = rsZip("County") Else Try LessonCMD.ExecuteNonQuery() Catch ex As Exception Response.Write("Sorry, there seems to be an issue. Please try entering the Zip Code the proper way and try again.") Finally rsZip.Close() LessonCon.Close() End Try End If End If End Sub End Class
Preview
Tags
protect our database from XSS and SQL Injection
protect our database from XSS and SQL Injection
protect our database from XSS and SQL Injection
protect our database from SQL Injection
protect our database from SQL Injection
protect our database from SQL Injection
Zip Code lookup form In An ASP.net
Zip Code lookup form In An ASP.net
Zip Code lookup form In An ASP.net
US Zip Code lookup form
US Zip Code lookup form
US Zip Code lookup form
protect our database from XSS Attacks
protect our database from XSS Attacks
VB.NET Zip Code Lookup
VB.NET Zip Code Lookup
VB.NET Protect against SQL Injection
VB.NET Protect against XSS Attacks
VB.NET Parameterized Queries