Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 76285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:38:58+00:00 2026-05-10T20:38:58+00:00

My question is similar to Engram’s here , but my question goes a bit

  • 0

My question is similar to Engram’s here, but my question goes a bit further. The way i intend it to work is I have a textbox asking how many entries a user is going to make. After they input the number, I need to create that many more textboxes to allow for entries (and then repeat the same process with those textboxes, but baby steps first…) I tried collecting the keys on the post, but it only returns the initial textbox asking for the number of entries. I’m still trying to get a grasp on MVC and the tutorials/videos so far don’t delve this deep into it yet. Then again, I know this is probably something I could handle using JQuery, but I’d still be stuck in the same situation.

This is the controller I’m using:

[AcceptVerbsAttribute("POST")]     public ActionResult Create(int tbxNumberOfExercises)     {         ViewData["number"] = tbxNumberOfExercises;         foreach (var key in Request.Form.Keys)         {             string keyString = key.ToString();             if (keyString.StartsWith("tbox_exercise", StringComparison.OrdinalIgnoreCase))             {                 string recNum = keyString.Substring(13, keyString.Length - 13);                 string approvedKey = Request.Form["tbox_exercise" + recNum];                 int number;                 int.TryParse(approvedKey, out number);             }         }         return View("Create");     } 

And this is my aspx:

<form action="/CreateWorkout/Create" method="post"> Number of Exercises: <%= Html.TextBox("tbxNumberOfExercises") %> <br /> <br /> <input type="submit" value="Set Exercise Number" /> </form> <% if (ViewData["number"] != null)%> There are this many:<%=Html.Encode(ViewData["number"])%> <br /> and this line should show up <% if (ViewData["number"] != null)    {        int max = (int)ViewData["number"];         for (int i = 0; i < max; i++)        {%>           <br />           <br />           <%= Html.TextBox("tbox_exercise" + i) %>     <% }    } %> <% if (ViewData["s"] != null) %> <%=Html.Encode(ViewData["s"]) %> 

Is there something I’m overlooking, not comprehending, or should I quit while I’m at it because it seems like I’ll never get it?

Thanks in advance for any help — I’m just trying to learn as most I can.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:38:59+00:00Added an answer on May 10, 2026 at 8:38 pm

    I’d break this up in stages, you’ll need to add a ‘Save’ view someplace depending on what you want.

    Scott

    <form action='/Demo01/Create' method='post'> Number of Exercises: <%= Html.TextBox('tbxNumberOfExercises') %> <br /> <br /> <input type='submit' value='Set Exercise Number' /> </form> <% if (ViewData['number'] != null) {%> <form action='/Demo01/Save' method='post'> There are this many:<%=Html.Encode(ViewData['number'])%> <br /> and this line should show up <% if (ViewData['number'] != null) {        int max = (int)ViewData['number'];         for (int i = 0; i < max; i++) {%> <br /> <br /> <%= Html.TextBox('tbox_exercise' + i) %> <% }    } %> <% if (ViewData['s'] != null) %> <%=Html.Encode(ViewData['s']) %> <input type='submit' value='Save Exercises' /> <% } %> </form> 

    And then in your controller something like this:

    public class Demo01Controller : Controller {     public ActionResult Create() {         return View();     }      [AcceptVerbsAttribute('POST')]     public ActionResult Create(int tbxNumberOfExercises) {         ViewData['number'] = tbxNumberOfExercises;         return View('Create');     }      [AcceptVerbs(HttpVerbs.Post)]     public ActionResult Save() {         foreach (var key in Request.Form.Keys) {             string keyString = key.ToString();             if (keyString.StartsWith('tbox_exercise', StringComparison.OrdinalIgnoreCase)) {                 string recNum = keyString.Substring(13, keyString.Length - 13);                 string approvedKey = Request.Form['tbox_exercise' + recNum];                 int number;                 int.TryParse(approvedKey, out number);             }         }         return View(); // return/redirect to wherever you want     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Similar question here but this is slightly different... I have two tables that I
I have asked a question similar to this in the past but this is
I have a question similar to This one . But I want to implement
A similar question has been asked, but since it always depends, I'm asking for
I have a question similar to here: using jquery.getJson with Google's GeoCoding HTTP Service
I have a question similar to this question but it is MonoTouch specific. When
A question similar to Locating bundles by identifier , but different problem: I have
I have a question similar to the one here: Event handlers inside a Javascript
Didn't see a question similar to this, so here goes: Let's say I'm running
I have a question similar to this but in the context of L2S. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.