title: Using AJAX to make multiple pages be called on one page. Create Person Method stopped working
body: <p>I have been searching on here on the web everywhere for two DAYS to find this. As of yet I have not found what I need. I am not sure if it is because I am doing something weird with AJAX or what but here is my problem if you can help please do.</p>
  
  <p>I am trying to make a website that only has multiple pages but uses AJAX and JQuery to give the illusion of having one page. The URL does not change like it is supposed to but when I try to create a salesperson or login using the AJAX loaded page it does not work. It looks like it does but it does not actually submit the data input as the code behind is never hit on the separate pages. The following code is my AJAX page.</p>
  
  <pre><code>/// &lt;reference path="jquery-1.8.2-vsdoc.js" /&gt;
  $(document).ready(function () {
  $('#ViewAllUsers').click(function () {
      $.ajax({
          type: 'POST',
          url: "/ViewAllUsers(test).aspx",
          success: function (result) {
              var main = $('#Main');
              main.html($('#Main', result).html());
          }
      });
  });
  $('#Button1').click(function () {
      $.ajax({
          type: 'POST',
          url: "/Login.aspx",
          success: function (result) {
              var main = $('#Main');
              main.html($('#Main', result).html());
          }
      });
  });
  $('#AddItem').click(function () {
      $.ajax({
          type: 'POST',
          url: "/admin/AddItem.aspx",
          success: function (result) {
              var main = $('#Main');
              main.html($('#Main', result).html());
          }
      });
  });
  $('#CreateSalesAccount').click(function () {
      $.ajax({
          type: 'POST',
          url: "/admin/CreateSalesAccount.aspx",
          success: function (result) {
              var main = $('#Main');
              main.html($('#Main', result).html());
          }
      });
  });
  $('#ViewAllOrderHistory').click(function () {
      $.ajax({
          type: 'POST',
          url: "/admin/ViewOrderHistory.aspx",
          success: function (result) {
              var main = $('#Main');
              main.html($('#Main', result).html());
          }
      });
  });
  });
  </code></pre>
  
  <p>This code is the admin page which is the page that uses the AJAX buttons to go to the other pages while staying on the admin page.</p>
  
  <pre><code>&lt;%@ Page Title="" Language="vb" AutoEventWireup="true" MasterPageFile="~/Site.Master" CodeBehind="AdminPage.aspx.vb" Inherits="PyriteGoldPresentation.AdminPage" %&gt;
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"&gt;
  &lt;script src="../Scripts/jquery-1.8.2.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../Scripts/PyriteGoldAjax.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
  &lt;div id = "Main"&gt;
      &lt;input type="button" id="ViewAllUsers" value="View All Users" /&gt;
      &lt;input type="button" id="AddItem" value = "Add Item" /&gt;
      &lt;input type="button" id="CreateSalesAccount" value="Create A Sales Account" /&gt;
      &lt;input type="button" id="ViewAllOrderHistory" value="View Order History" /&gt;
  &lt;/div&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>And Finnaly here is the create salesman page and the code behind it.</p>
  
  <pre><code>&lt;%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="CreateSalesAccount.aspx.vb" Inherits="PyriteGoldPresentation.CreateSalesAccount"%&gt;
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"&gt;
  &lt;script src="../Scripts/jquery-1.8.2.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../Scripts/PyriteGoldAjax.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
  &lt;div id="Main"&gt;
      &lt;div style="width: 400px; margin-left:auto; margin-right:auto;"&gt;
          &lt;div class="row"&gt;
              &lt;h2&gt;
                  Create Sales Account
              &lt;/h2&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
              &lt;span class="column1"&gt;
                  &lt;asp:Label ID="FirstNameLabel" runat="server" Text="First Name"/&gt;
              &lt;/span&gt;
              &lt;span class="column2"&gt;
                  &lt;asp:TextBox ID="FirstNameTextField" runat="server" Width="137px"/&gt;
              &lt;/span&gt;
              &lt;span class="column3"&gt;
                  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*Required Field"
                   ControlToValidate="FirstNameTextField"/&gt;
              &lt;/span&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
              &lt;span class="column1"&gt;
                  &lt;asp:Label ID="LastNameLabel" runat="server" Text="Last Name"/&gt;
              &lt;/span&gt;
              &lt;span class="column2"&gt;
                  &lt;asp:TextBox ID="LastNameTextBox" runat="server" Width="137px"/&gt;
              &lt;/span&gt;
              &lt;span class="column3"&gt;
                  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*Required Field" ControlToValidate="LastNameTextBox"/&gt;
              &lt;/span&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
              &lt;span class="column1"&gt;
                  &lt;asp:Label ID="EmailLabel" runat="server" Text="E-Mail Address"/&gt;
              &lt;/span&gt;
              &lt;span class="column2"&gt;
                  &lt;asp:TextBox ID="EmailTextBox" runat="server" Width="134px"/&gt;
              &lt;/span&gt;
              &lt;span class="column3"&gt;
                  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="*Required Field" ControlToValidate="EmailTextBox"/&gt;
              &lt;/span&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
              &lt;span class="column1"&gt;
                  &lt;asp:Label ID="VerifyEmailLabel" runat="server" Text="Verify E-Mail"/&gt;
              &lt;/span&gt;
              &lt;span class="column2"&gt;
                  &lt;asp:TextBox ID="VerifyEmailTextBox" runat="server" Width="136px"/&gt;
              &lt;/span&gt;
              &lt;span class="column3"&gt;
                  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="*Required Field" ControlToValidate="VerifyEmailTextBox"/&gt;
              &lt;/span&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
              &lt;span class="column1"&gt;
                  &lt;asp:Label ID="PasswordLabel" runat="server" Text="Password"/&gt;
              &lt;/span&gt;
              &lt;span class="column2"&gt;
                  &lt;asp:TextBox ID="PasswordTextBox" runat="server" Width="138px" 
                  TextMode="Password"/&gt;
              &lt;/span&gt;
              &lt;span class="column3"&gt;
                  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="*Required Field" ControlToValidate="PasswordTextBox"/&gt;
              &lt;/span&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
              &lt;span class="column1"&gt;
                  &lt;asp:Label ID="VerifyPasswordLabel" runat="server" Text="Verify Password"/&gt;
              &lt;/span&gt;
              &lt;span class="column2"&gt;
                  &lt;asp:TextBox ID="VerifyPasswordTextBox" runat="server" Width="138px" 
                  TextMode="Password"/&gt;
              &lt;/span&gt;
              &lt;span class="column3"&gt;
                  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="*Required Field" ControlToValidate="VerifyPasswordTextBox"/&gt;
              &lt;/span&gt;
          &lt;/div&gt;
          &lt;div class="row" style="color:Red;"&gt;
              &lt;asp:CompareValidator ID="EmailValidator" runat="server" ErrorMessage="**E-mail Feilds Must Match" ControlToCompare="EmailTextBox" ControlToValidate="VerifyEmailTextBox"/&gt;&lt;br /&gt;
              &lt;asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
              ErrorMessage="**E-mail Addresses must follow the pattern user@domain.com" ControlToValidate="EmailTextBox" 
              ValidationExpression="\w+([-+.']\w+[-]*)*@\w+([-.]*\w+)*\.\w+([-.]\w+)*"/&gt;&lt;br /&gt;
              &lt;asp:CompareValidator ID="PasswordValidator" runat="server" ErrorMessage="**Password Fields Must Match" ControlToCompare="PasswordTextBox" ControlToValidate="VerifyPasswordTextBox"/&gt;
          &lt;/div&gt;
          &lt;div&gt;
              &lt;asp:Button ID="SubmitButton" runat="server" Text="Submit" OnClick="SubmitButton_Click" /&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>Code Behind </p>
  
  <pre><code>Imports PyriteGoldBLL
  Imports PyriteGoldModel
  
  Public Class CreateSalesAccount
  Inherits System.Web.UI.Page
  
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      If Session("permissionValue") &lt;&gt; 3 Then
          Response.Redirect("~/Home.aspx")
      End If
  End Sub
  
  Protected Sub SubmitButton_Click(sender As Object, e As EventArgs) Handles SubmitButton.Click
      Dim userLogic As New UserLogic()
      Dim user As New User()
      With user
          .FirstName = FirstNameTextField.Text
          .LastName = LastNameTextBox.Text
          .Email = EmailTextBox.Text
          .Password = PasswordTextBox.Text
          .Activated = True
          .Permission = 2
      End With
      userLogic.CreateUser(user)
  End Sub
  </code></pre>
  
  <p>End Class</p>