<Redirect>

New to Version 4.0! The Redirect action tag will send the user to the specified URL (Target) at run-time. In previous versions you could set a redirect target on the Add and Update button tags and you still can. However, the Redirect tag allows you to perform conditional redirects based on form data.

Syntax

<Redirect
    If="expression"
    Target="Redirect address"
    Method="string" />
 

Remarks

Back to top

Example

<AddForm>
  <SubmitCommand CommandText="INSERT INTO Users(FirstName, LastName) VALUES(@FirstName, @LastName)" />
  <table>
    <tr>
      <td>
         <Label For="txtFirstName" Text="First Name" />
         <TextBox Id="txtFirstName" DataField="FirstName" DataType="string" />
       </td>
    </tr>
    <tr>
      <td>
        <Label For="txtLastName" Text="Last Name" />
        <
TextBox Id="txtLastName" DataField="LastName" DataType="string" />
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <AddButton Text="Add" Redirect="/Find.aspx" /> <CancelButton Text="Cancel"/>
      </td>
    </tr>
  </table>
<Redirect Target="/Find.aspx?ln=Smith" Method="Get" If="[[LastName]] = Smith" />
  <Redirect Target="/Find.aspx?ln=Jones" Method="Get" If="[[LastName]] = Jones" />
</AddForm>

In the example above, there are 3 possible redirections that can occur based on user input. If the user enters a last name of "Smith" or "smith" she will be redirected to the URL: /Find.aspx?ln=Smith. If the user enters "Jones" or "jones" then they will be redirected to the URL: /Find.aspx?ln=Jones. If the user doesn't enter anything or enters some other name or value, they will be sent to the default URL specified on the AddButton tag: /Find.aspx where, presumably, all records - regardless of last name - would be listed.

 

Back to top