View Single Post
  #7 (permalink)  
Old August 27th, 2008, 03:45 PM
Old Pedant Old Pedant is offline
Friend of Wrox
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

If this is a page that posts back to itself, then there's no reason to use Request["xxx"]. Just use the same kind of code you would on a code-behind page.

Yes, an "all-in-one" page is perfectly legal in ASP.NET.

Hmmm...let me see if I have one sitting around for demo purposes...

Well, I don't have one in C# and the one in VB.NET is pretty silly, but still... It does work and does show that you just work with form fields same as you do in code-behind.

<%@ Page Language="VB" AutoEventWireup="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        <asp:CheckBox ID="CheckBox1" runat="server" />
    <% If Session("xyz") = "xyz" Then%>
    <% End If  %>
    <% If Checkbox1.Checked Then Session("xyz") = "xyz" %>
    <asp:Button ID="doSubmit" Text="Test!" runat=server />
Reply With Quote