Vous êtes sur la page 1sur 5

INTEGRATING ONLINE CREDIT CARD TRANSACTIONS

This is the best reason to password protect your online content using AuthentiX. By integrating with preferred online credit card clearers , you can
automatically add students to your AuthentiX database once their credit card has been charged. The AuthentiX database is updated with the users
expiration date, making it easy to manage and delete expired accounts.

But how do you accomplish this? Simply choose a script from one of our preferred online credit card clearers, install it into a script enabled directory on
your server - after you have arranged for service through the clearer, of course.

Here is a quick overview of how the integration process works:

1. The user goes to your website. In this case, they are not already a member, so they must purchase access to the online content. They click a link (usually
'Buy Now') which provides them with an online purchase form. Your online credit card clearer will be able to give you a template of the 'purchase form'.

2. The user fills out the form with their information (including billing address and credit card information), and then clicks 'submit'. This process posts (aka
'gives') the form to the online credit card clearer.

3. The online credit card clearer ensures that the information is valid, subsequently charging the credit card. Then the online credit card clearer posts the
username,password, and expiration date to the SubscriptiX integration script, which you have, by now, put on your website server.

4. Upon receiving the information (username,password, and expiration date) from the credit card clearer, the SubscriptiX integration script adds the new
user to the AuthentiX internal database.

5. The next time the user goes to the website, they will gain access by simply typing in their usernames and password (Cookie Based authentication does
not require the user to enter in their username/password. They will be allowed access only if they have the correct cookie). When the expiration day comes,
their access status is changed within the AuthentiX database.

So what have we accomplished? Using AuthentiX, we have password protected our distant learning web content. Your students can change their own
passwords, email forgotten passwords to themselves, and even pay for their classes online! Now you can focus on the most important part of your website
- content development.

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc.
The content provided is intended for entertainment and/or educational purposes in order to introduce to the
reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-
world tactics for security and implementation of best practices. We are not liable for any negative
consequences that may result from implementing any information covered in our articles or tutorials. If this
is a hardware review, it is not recommended to open and/or modify your hardware.
More ASP.NET Code Articles

This is a updated demo to create form wizard using an aspx page and code-behind in VB.NET

<%@ Page Language="vb" EnableSessionState="False" EnableViewState="True" Trace="False" Debug="False" Inherits="createformcode"


src="createformcode.vb" %>
<HTML>
<HEAD>
<title></title>
</HEAD>
<body bgcolor="#ffffff">
<form runat="server" id="form1">
Select a tablename to create a .NET form for:
<asp:dropdownlist id="tblList" runat="server" />&nbsp;&nbsp;
<asp:Button id="GetTable" Text="Get Table" onclick="GetTable_Click" runat="server" />
<asp:panel id="myPanel" runat="server" visible="false"><BR>Select the
Columns used for generating the form.
<asp:datagrid id="MyDataGrid" runat="server" AutoGenerateColumns="False" HeaderStyle-BackColor="#aaaadd" Font-Size="8pt" Font-
Name="Verdana" CellPadding="3" BorderWidth="1" BorderColor="black">
<Columns>
<asp:TemplateColumn HeaderText="Add?">
<ItemTemplate>

<asp:CheckBox id="chkAdd" runat="server" />

</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="Name" DataField="name" />
<asp:TemplateColumn HeaderText="Create Validator?">
<ItemTemplate>

<asp:CheckBox id="chkValid" runat="server" />

</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
<asp:Button id="Button1" onclick="btnSubmit_Click" runat="server" Text="Create Form"></asp:Button> </asp:panel>
<asp:panel id="pnlTextarea" visible="false" runat="server">
<P>Copy this code into a new ASP.NET page</P>
<TEXTAREA id="taResults" name="taResults" rows="40" cols="90" runat="server"> &lt;/asp:panel&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;
</TEXTAREA>
</asp:panel>
</form>
</body>
</HTML>

Imports System
Imports System.Text
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web
Imports System.Web.UI.WebControls
Imports System.Web.UI.HTMLControls
Imports Microsoft.VisualBasic

Public Class createformcode: Inherits System.Web.UI.Page

Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox


Protected WithEvents MyDataGrid As System.Web.UI.WebControls.DataGrid
Protected WithEvents taResults As System.Web.UI.HtmlControls.HtmlTextArea
Protected WithEvents pnlTextarea As System.Web.UI.WebControls.Panel
Protected WithEvents myPanel As System.Web.UI.WebControls.Panel
Protected WithEvents tblList As System.Web.UI.WebControls.DropDownList
Protected WithEvents GetTable As System.Web.UI.WebControls.Button
Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button

Dim sqlText As String


Dim ds As New DataSet()
Dim dbComm As New SqlDataAdapter()
Dim conn As SqlConnection
Dim sqlServer As String

Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

sqlServer = GetSqlConn()
conn = New SqlConnection(sqlServer)
If Not IsPostBack Then
sqlText = "select id, name from sysobjects where xtype='U' order by name"
dbComm = New SqlDataAdapter(sqlText, conn)
dbComm.Fill(ds, "AllTables")
tblList.DataSource = ds.Tables("AllTables").DefaultView
tblList.DataTextField = "name"
tblList.DataValueField = "name"
tblList.DataBind()
End If
End Sub

Function CreateValidator(ByVal myName As String) As String


Dim mySB As StringBuilder = New StringBuilder()

REM -- use :<some text>: as placeholders


mySB.Append("<asp:RequiredFieldValidator runat=""server"" id="":Name:"" ControlToValidate="":control:"" ErrorMessage="":errMsg:""
display=""Static"">This Required Field!</asp:RequiredFieldValidator>")

mySB.Replace(":Name:", "vld" & myName) 'add the validator name


mySB.Replace(":control:", "at" & myName) 'add the control name
mySB.Replace(":errMsg:", myName & " is required")

Return mySB.ToString()
End Function

Function GetSqlConn() As String


Dim DSN As String = ConfigurationSettings.AppSettings("DSN")
Return DSN
End Function

Sub GetTable_Click(ByVal sender As Object, ByVal e As EventArgs)


Dim sqlText As String
sqlText = "SELECT syscolumns.name, syscolumns.isnullable FROM sysobjects INNER JOIN syscolumns ON sysobjects.id = syscolumns.id where
sysobjects.name = '" & tblList.SelectedItem.Text & "' ORDER BY syscolumns.colid"

REM -- Connect to SQL


dbComm = New SqlDataAdapter(sqlText, conn)

REM -- Fill DataSet


dbComm.Fill(ds, "TestData")
MyDataGrid.DataSource = ds.Tables("TestData").DefaultView
MyDataGrid.DataBind()

REM -- Show the results


myPanel.Visible = True

End Sub

Public Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

Dim i As Integer
Dim _item As DataGridItem
Dim dr As DataRow
Dim sb As StringBuilder = New StringBuilder()
Dim strOutput As String

REM -- Auto Generate The Form


sb.Append("<form runat=""server"" id=""form2"" name=""form2"">" & chr(13) & chr(10))
sb.Append(" <table border=1>")

For i = 0 To MyDataGrid.Items.Count - 1
REM -- Get the checkbox
_item = MyDataGrid.Items(i)
Dim addCheckBox As CheckBox = Ctype(_item.FindControl("chkAdd"), CheckBox)
Dim validCheckBox As CheckBox = Ctype(_item.FindControl("chkValid"), CheckBox)

If addCheckBox.Checked Then
sb.Append(" <tr>" & chr(13))
sb.Append(" <td>" & _item.Cells(1).Text & "</td>" & chr(13))
sb.Append(" <td>")
sb.Append("<asp:textbox id=""at" & _item.Cells(1).Text & """ runat=""server"" />")

'create a validator control


If validCheckBox.Checked Then
sb.Append(" " & vbCrLf & CreateValidator(_item.Cells(1).Text))
End If

sb.Append("</td>" & chr(13)) '


sb.Append(" </tr>" & chr(13)) ' close out the row
End If

Next
sb.Append(" <tr>" & chr(13)) ' close out the row
sb.Append(" <td colspan=""2""><asp:button id=""button1"" Text=""Validate Form"" runat=""Server"" /></td>" & vbCrLf)
sb.Append(" </tr>" & chr(13)) ' close out the row
sb.Append(" </table>" & chr(13))
sb.Append(vbCrLf & "</form>")
strOutput = sb.ToString()
strOutput = System.Web.HttpUtility.HtmlEncode(strOutput)
taResults.Value = strOutput
pnlTextarea.Visible = True
End Sub

Private Sub InitializeComponent()

End Sub
End Class

How to send email from asp+pages

This is code to do such things


Top of Form
<%@ Page Language="VB" EnableSessionState="False" EnableViewState="False" Trace="False" Debug="False" Strict="True" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat=server>
Sub Page_load(Sender as Object, E as EventArgs)

If request.form("EmailAddress") = "" Then


dim strResponse as string = "<h2>Send Email using ASP.NET formatted in HTML</h2>"
lblMessage.Text = strResponse
Else
dim strResponse as string = "You just sent an email message formatted in HTML to:<br><h2>" & request("EmailAddress") & "</h2>"
lblMessage.Text = strResponse
End If

End Sub

Sub btn_Click(sender as Object, e as System.EventArgs)

If request.form("EmailAddress") <> ""


Dim mail As New MailMessage
mail.From = "youraddress@domain.com"
mail.To = request.form("EmailAddress")
mail.Subject = "Message sent using ASP.NET and CDONTS"
mail.Body = "HTML Message sent from ASPFree.com using ASP.NET and Cdonts<br><a href='http://aspfree.com/aspnet/email.aspx'>Wonder how this is
done?</a><br><br><a href='http://aspfree.com/aspnet/setupcdonts.aspx'>Wonder How to setup CDONTS?</a>"
mail.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "LocalServerName"
SmtpMail.Send(mail)
End If
End Sub

</script>
<html>
<head>
</head>
<body>
<h1 align="center">Sending Email via ASP.NET and CDONTS..</h1>
<b><a href="/aspnet/setupcdonts.aspx">How do I setup my server to use CDONTS?</a></b>
<br />
<br />
<a href="/allzips/emaildotnet.zip"><img src="http://aspfree.com/images/downloadcode.gif" border="0"></a>
<br />
<br />
<asp:Label id="lblMessage" Font-Name="Verdana" Width="400px" BorderStyle="solid" BorderColor="#cccccc" runat="server"/>

<form method="post" name="form1" runat="server" runat="server">


Email Address:<input type="text" name="EmailAddress" size="30" value=""><br><br>
<input type="Submit" id="btnSubmit" OnServerClick="btn_Click" value="Sending Email with ASP.NET" name="b1" runat="server" />
</form>
</body>
</html>
Bottom of Form
This article shows how to pass a string of text from a TEXTBOX server control to a routine that replaces words in the string. This is handy in replacing
words before they get committed to the database, email or where ever this text is being sent. A dataset is created to and uses the READXML method to
read an XML file into the newly created dataset to compare the words.

Here is the code:

<%@ Page Debug="True" Language="vb" %>


<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SQLClient" %>
<script runat="server">
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Page.IsPostBack Then
Dim w As String = Request.Form("TextBox1")
Label1.Text = "Statement with Replaced words:<b>" & badWords(w) & "</b>"
End If
End Sub

Function badWords(mytext As String) As String


Dim badWordsDS As New DataSet("Dataset")
Dim myRow As DataRow

badWordsDS.ReadXml(Server.Mappath("badwords.xml"))

Dim ct As Integer
ct = badWordsDS.Tables(0).Rows.Count
label2.text = "Amount of Records in XML file: <b>" & ct.ToString() & "</b>"

For Each myRow In badWordsDS.Tables(0).Rows


mytext = mytext.ToLower.Replace(myRow(0).ToString(), "ReplacementText")
Next

Return mytext
End Function
</script>
<html>
<head>
<title>Replace text using XML File</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
<br />
<b>Textbox data</b>
<br />
<asp:Label id="Label1" runat="server">Statement with Replaced words</asp:Label>
<br />
<br />
<b>Amount of records in XML file</b>
<br />
<asp:Label id="Label2" runat="server">Amount of Words in XML file</asp:Label>
</form>
</body>
</html>

XML File used in replacing text


<swearwords>
<menu>
<word>badword</word>
</menu>
<menu>
<word>badword2</word>
</menu>
</swearwords>

Vous aimerez peut-être aussi