Bug tracker: Create the BugForm view

After you create the BugModel class, you create the BugForm view. The BugForm view represents a form that is used by the user to log a new bug. To create the BugForm view:

  1. In Visual Studio, navigate to the Areas » BugTracker » Views » Bug folder, create a new file with the cshtml extension.
    Name the file BugForm.
  2. Add using statements to the following namespaces:
    • Telerik.Web.Mvc.UI
    • Telerik.Sitefinity.Model
    • Telerik.Sitefinity.DynamicModules.Model
  3. Set the layout of the view.
    Use the BugTrackerLyout view as the layout.
  4. Define a form:
    1. Use the BeginForm method of the HtmlHelper object.
    2. Specify the action, controller and the route values. The form navigates to the specified URL after it is submitted.
    3. Specify the method of the form to be FormMethod.Post.
      Note that you have to put the call to the BeginForm method inside a using clause.
  5. Define the input fields:
    1. Inside the using clause for the BeginForm method, create a fieldset element.
    2. Inside the element define the input fields for the bug details.
      When defining the choice fields, set their values to the same values as the one defined for the Bug content type in the custom module. Note that the names of the input fields must be the same as the names of the properties of the BugModel class.

GITHUB EXAMPLE: For more information about the content of the file, see the BugForm.cshtml file of the downloaded sample project.

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?