<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Lisa Wollin : Classic ASP</title><link>http://blogs.msdn.com/lisawoll/archive/tags/Classic+ASP/default.aspx</link><description>Tags: Classic ASP</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Password Protecting Web Pages</title><link>http://blogs.msdn.com/lisawoll/archive/2005/06/24/432429.aspx</link><pubDate>Sat, 25 Jun 2005 01:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:432429</guid><dc:creator>lisawoll</dc:creator><slash:comments>27</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/432429.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=432429</wfw:commentRss><description>&lt;P&gt;John Jansen, one of the FrontPage testers, sent me these three different ways to password protect pages in FrontPage.&lt;/P&gt;
&lt;P&gt;&lt;A href="#gui"&gt;Using a FrontPage site template and ASP&lt;/A&gt;&lt;BR&gt;&lt;A href="#snippets"&gt;Using Code Snippets&lt;/A&gt;&lt;BR&gt;&lt;A href="#aspnet"&gt;Using ASP.NET&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A name=gui&gt;&lt;/A&gt;&lt;STRONG&gt;To password protect pages using a FrontPage site template and ASP&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Here are specific steps to password protect pages using features built into FrontPage:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;From the &lt;STRONG&gt;File&lt;/STRONG&gt; menu, click &lt;STRONG&gt;New&lt;/STRONG&gt;. 
&lt;LI&gt;From the &lt;STRONG&gt;Web Site&lt;/STRONG&gt; tab, select &lt;STRONG&gt;FrontPage Server Templates&lt;/STRONG&gt; from the first list, and then select &lt;STRONG&gt;Database Interface Wizard&lt;/STRONG&gt; from the second list. 
&lt;LI&gt;Type the location where you want to put your password protected page. This must be an Windows Web server running IIS. 
&lt;LI&gt;Click &lt;STRONG&gt;OK&lt;/STRONG&gt;. 
&lt;LI&gt;In the Wizard… 
&lt;OL&gt;
&lt;LI&gt;Click &lt;B&gt;Next&lt;/B&gt; to create an ASP solution. 
&lt;LI&gt;Click &lt;B&gt;Next&lt;/B&gt; to use the default name for the connection. 
&lt;LI&gt;Click &lt;B&gt;Next&lt;/B&gt; to use the default columns in the table. 
&lt;LI&gt;Click &lt;B&gt;Next&lt;/B&gt; after the DB is created. 
&lt;LI&gt;Click &lt;B&gt;Next&lt;/B&gt; to use the default table. 
&lt;LI&gt;Check the box to use a Database Editor. 
&lt;LI&gt;Click &lt;B&gt;Next&lt;/B&gt;. 
&lt;LI&gt;Choose a password and enter it. 
&lt;LI&gt;Click &lt;B&gt;Next&lt;/B&gt;. 
&lt;LI&gt;Click &lt;B&gt;Finish&lt;/B&gt;. &lt;/LI&gt;&lt;/OL&gt;
&lt;LI&gt;After FrontPage finishes building the site, all of the necessary code for password protecting pages has been generated. In order to protect any new pages, simply put the following code:&lt;BR&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;!-- #include file=”login.asa” --&amp;gt;
&amp;lt;%
If Session(SiteId) &amp;lt;&amp;gt; true Then
Response.Redirect(“login.asp?requester=&amp;lt;!--insert page name here--&amp;gt;”)
End If
%&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;above the &lt;CODE&gt;&amp;lt;HTML&amp;gt;&lt;/CODE&gt; tag on any page and save as .asp. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;A name=snippets&gt;&lt;/A&gt;&lt;STRONG&gt;To password protect pages using Code Snippets&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Here are steps to create password protected pages using code snippets:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a new site in FrontPage. 
&lt;LI&gt;Create a new page and switch to Code view. 
&lt;LI&gt;Delete all the code in the new page. 
&lt;LI&gt;Paste the following code as a code snippet.&lt;PRE&gt;&amp;lt;%
Username="user"
Password="pass"
' if any of the variables do not match, create error message
if Request.Form("login") &amp;lt;&amp;gt; Username or Request.Form("password") &amp;lt;&amp;gt; Password then
    MsgErr = "&amp;lt;h3&amp;gt;Authorization Failed.&amp;lt;/h3&amp;gt;"
    Response.Write MsgErr
    ' if correct, set the session variable and proceed
Else
    Session("someStringValue") = true
    ' redirect
    If Len(Request("requester")) &amp;gt; 0 Then
        Response.Redirect (Request("requester"))
    Else
        Response.Redirect "protected.asp"
    End if
End if
%&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Results -- Login&amp;lt;/title&amp;gt;
    &amp;lt;meta http-equiv="Content-Type" content="text/html; charset=windows-1252"&amp;gt;
    &amp;lt;meta name="GENERATOR" content="Microsoft FrontPage 6.0"&amp;gt;
    &amp;lt;meta name="ProgId" content="FrontPage.Editor.Document"&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body bgcolor="#FFFFFF"&amp;gt;
    &amp;lt;FORM ACTION="login.asp" METHOD="post"&amp;gt;
    &amp;lt;h3&amp;gt;Login&amp;lt;/h3&amp;gt;
        &amp;lt;TABLE BORDER=0&amp;gt; 
            &amp;lt;TR&amp;gt;
                &amp;lt;TD ALIGN="right"&amp;gt;User name:&amp;lt;/TD&amp;gt;
                &amp;lt;TD&amp;gt;&amp;lt;INPUT TYPE="text" NAME="login" size="10" VALUE=''/&amp;gt;&amp;lt;/TD&amp;gt;
            &amp;lt;/TR&amp;gt;
            &amp;lt;TR&amp;gt;
                &amp;lt;TD ALIGN="right"&amp;gt;Password:&amp;lt;/TD&amp;gt;
                &amp;lt;TD&amp;gt;&amp;lt;INPUT TYPE="password" NAME="password" size="10" VALUE=''/&amp;gt;&amp;lt;/TD&amp;gt;
            &amp;lt;/TR&amp;gt;
            &amp;lt;TR&amp;gt;
                &amp;lt;TD&amp;gt;&amp;lt;input TYPE="hidden" NAME="requester" VALUE="&amp;lt;%=Server.HtmlEncode(Request("requester"))%&amp;gt;"&amp;gt;&amp;lt;/TD&amp;gt;
                &amp;lt;TD&amp;gt;&amp;lt;/TD&amp;gt;
            &amp;lt;/TR&amp;gt;
            &amp;lt;TR&amp;gt;
                &amp;lt;TD align="left"&amp;gt;&amp;lt;INPUT TYPE="submit" VALUE="Login"/&amp;gt;&amp;lt;/TD&amp;gt;
                &amp;lt;TD&amp;gt;&amp;lt;/TD&amp;gt;
            &amp;lt;/TR&amp;gt;
        &amp;lt;/TABLE&amp;gt;
    &amp;lt;/FORM&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/PRE&gt;
&lt;LI&gt;Save page as login.asp. 
&lt;LI&gt;Create a new page and switch to Code view (or do this with any page you want to protect with a password). 
&lt;LI&gt;Above the opening &amp;lt;html&amp;gt; tag, paste in the following snippet. &lt;PRE&gt;&lt;CODE&gt;&amp;lt;%
If Session("someStringValue") &amp;lt;&amp;gt; true Then
    Response.Redirect("Login.asp?requester=protected.asp")
End If
%&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;LI&gt;Save this page as protected.asp (or replace the requester text above from protected.asp to the page name you are protecting). 
&lt;LI&gt;Browse to protected.asp. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;A name=aspnet&gt;&lt;/A&gt;&lt;STRONG&gt;To password protect pages using ASP.NET&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Here are steps to password protect pages using ASP.NET:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a new page in your Web site and switch to code view. 
&lt;LI&gt;Select and delete all the code in the page. 
&lt;LI&gt;Paste in the following code. &lt;PRE&gt;&lt;CODE&gt;&amp;lt;html&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;Please Log In&amp;lt;/h1&amp;gt;
    &amp;lt;hr&amp;gt;
    &amp;lt;form runat="server"&amp;gt;
    &amp;lt;table cellpadding="8"&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;User Name:&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;asp:TextBox ID="UserName" RunAt="server" /&amp;gt;&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;Password:&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;asp:TextBox ID="Password" TextMode="password" RunAt="server" /&amp;gt;&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;asp:Button Text="Log In" OnClick="OnLogIn" RunAt="server" /&amp;gt;&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
    &amp;lt;/table&amp;gt;
    &amp;lt;/form&amp;gt;
    &amp;lt;hr&amp;gt;
    &amp;lt;h3&amp;gt;&amp;lt;asp:Label ID="Output" RunAt="server" /&amp;gt;&amp;lt;/h3&amp;gt;
    &amp;lt;/body&amp;gt;
    &amp;lt;/html&amp;gt;
    &amp;lt;script language="C#" runat="server"&amp;gt;
        void OnLogIn (Object sender, EventArgs e)
        {
            if (FormsAuthentication.Authenticate (UserName.Text, Password.Text))
                FormsAuthentication.RedirectFromLoginPage (UserName.Text, false);
            else
                Output.Text = "Invalid login";
        }
    &amp;lt;/script&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;LI&gt;Save the page as loginpage.aspx. 
&lt;LI&gt;Create a new page and switch to code view. 
&lt;LI&gt;Select and delete the code in the page. 
&lt;LI&gt;Paste the following code into the new page. &lt;PRE&gt;&lt;CODE&gt;&amp;lt;configuration&amp;gt;
    &amp;lt;system.web&amp;gt;
        &amp;lt;authentication mode="Forms"&amp;gt;
        &amp;lt;forms loginUrl="LoginPage.aspx"&amp;gt;
        &amp;lt;credentials passwordFormat="Clear"&amp;gt;
    &amp;lt;user name="Bruce" password="Batman"/&amp;gt;
    &amp;lt;/credentials&amp;gt;
    &amp;lt;/forms&amp;gt;
    &amp;lt;/authentication&amp;gt;
    &amp;lt;authorization&amp;gt;
    &amp;lt;deny users="?" /&amp;gt;
    &amp;lt;/authorization&amp;gt;
    &amp;lt;/system.web&amp;gt;
&amp;lt;/configuration&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;LI&gt;Save the page as web.config. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;And that’s all there is to that. Any aspx pages in the same folder as the web.config file are protected.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=432429" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Classic+ASP/default.aspx">Classic ASP</category></item><item><title>Creating ASP event handlers</title><link>http://blogs.msdn.com/lisawoll/archive/2004/07/22/191692.aspx</link><pubDate>Thu, 22 Jul 2004 22:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:191692</guid><dc:creator>lisawoll</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/191692.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=191692</wfw:commentRss><description>&lt;p&gt;Here's another tip from &lt;a href="http://www.richklein.us/bio.htm"&gt;Rich Klein&lt;/a&gt; about how to 
create event handler for classic ASP code.&lt;/p&gt;
&lt;p&gt;If you&amp;#8217;ve ever tried to
program an event handler for option buttons (also know as radio buttons) in
ASP, you know this can be a daunting task. Option buttons do not automatically
fire events in a way that can be easily trapped using VBScript. You must
specify the event handler for each event when defining the control.&lt;/p&gt;
&lt;p&gt;For example, if you want
to populate a variable value when a particular option button is clicked, you
might try something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;rdoButton&amp;quot; OnClick=&amp;quot;rdoButton_OnClick('12')&amp;quot;&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Because this option button
is using a well-defined event tag, including a language attribute is not always
necessary, but in other cases, it may be necessary. For example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;rdoButton&amp;quot; OnClick=&amp;quot;rdoButton_OnClick('12')&amp;quot; language=&amp;quot;vbscript&amp;quot;&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Using a language
attribute ensures the ASP interpreter knows how to handle the event. Without the
attribute, the interpreter may try to parse the statement using rules for
JavaScript and produce an error when the statement does not conform.&lt;/p&gt;
&lt;p&gt;Additionally, option buttons
have other quirks. The biggest one I&amp;#8217;ve found so far is the fact that if you
are creating a dynamic list from a table of data, you would logically place the
button in a statement loop. If you define each button with a unique name&amp;#8212;for
example, the name is terminated by the value of a loop counter&amp;#8212;each option button
would operate on its own, allowing a user to click more than one button.&lt;/p&gt;
&lt;p&gt;If you create each button
using the same variable name, then the buttons behave as intended, but now you
must access them as an array control, which means that you must use a
subscripted reference to the variable name. For example, using the preceding code,
&amp;quot;rdoButton(0)&amp;quot; would reference the first option button in the group.&lt;/p&gt;
&lt;p&gt;The problem here is that
when you are dealing with dynamic data, you won&amp;#8217;t always know how many records
are returned. This might not be an issue, but in the case in which only one
record is returned and there is only one option button, the control cannot be
referenced as a control array; it must be referenced as an individual control.
Referencing it as an array returns an error because there is no subscript to
reference.&lt;/p&gt;
&lt;p&gt;To work around this
behavior, define the control with a value attribute &lt;i&gt;and&lt;/i&gt; a parameter that
is passed in the event handler you define.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;rdoButton&amp;quot; value=&amp;quot;12&amp;quot; OnClick=&amp;quot;rdoButton_OnClick('12')&amp;quot; language=&amp;quot;vbscript&amp;quot;&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then when creating the
event handler in the script, do something like the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;script language=&amp;quot;vbscript&amp;quot;&amp;gt;
   Sub rdoButton_OnClick(varNum)
      If IsNumeric(varNum) then
         form.hCurrentRecord.value = varNum
      Else
         form.hcurrentRecord.value = form.rdoButton.value
      End If
   End Sub
&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;The 'form'
designation is the name given to the form object in which the option buttons
are contained.&lt;/p&gt;
&lt;p&gt;By using this format, you
avoid entirely the necessity of finding the array subscript of the option button
and the error produced if trying to reference the non-existent array value of a
single button. As a side note, if you place an alert in the first line of the
sub that displays the value of the variable passed in 'varNum', you will see
that, in the case of a single option button, the event fires twice. The first
time it displays the proper value passed, and the second time it displays a
reference to the object. This is why getting the value from the control is
necessary. This technique could probably be simplified further by just ignoring
the second event. Then the Else clause would not be required and the value
attribute in the option buttons could be eliminated.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=191692" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Classic+ASP/default.aspx">Classic ASP</category></item></channel></rss>