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
Default

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.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CheckBox ID="CheckBox1" runat="server" />
    <% If Session("xyz") = "xyz" Then%>
    <script>alert("yowser");</script>
    <% End If  %>
    <% If Checkbox1.Checked Then Session("xyz") = "xyz" %>
    <p>
    <asp:Button ID="doSubmit" Text="Test!" runat=server />
    </p>
    </div>
    </form>
</body>
</html>
Reply With Quote