PDA

View Full Version : Form with steps


QBall777
11-18-2008, 03:08 PM
Hi

I'm attempting to build a form in .NET with 7 steps. I do not want the user to jump a step, so I was wondering is there away that the steps could be greyed out and locked until the previous step is complete.

If there are any tutorials on this kind of thing I would really appreciate a link.

Thanks

Freon22
11-18-2008, 06:17 PM
So these 7 steps are they each one a different page or are all 7 steps on the same page?

If they are on different pages then create a session so inorder to go to the next step the session has to equal something. If all the steps are on the same page then use panels

<asp:Panel ID="step1" runat="server" Visible="true">
Step One
</asp:Panel>
<asp:Panel ID="step2" runat="server" Visible="false">
Step Two.
</asp:Panel>
.... and so on.

In each panel have a button that they click when they are done which postest the infor to your database and sets the visible of step1 to false and the visible of step2 to true. Or if you want you can set your textbox to ReadOnly. You have to give more infor to what you are doing because there are so many ways of doing this. Like you could even use the asp Wizard. Also are you talking about webForms or winForms?

QBall777
11-19-2008, 07:15 AM
Hi Freon thanks for the quick response.

I have nether done anything like this before so I don't really know the best method. I was gonna have all the steps on one page but I think it may get a little busy.

My first idea was to build the form like I do with any contact form where the user fills in their details and then it gets emailed to the client, but I'm guessing this is not the correct way to do it.

Do I have to use a database?

What method would you use? I think the steps on different pages works well but I do not want to use the asp.wizard (prefer to try and learn from scratch)

Thanks for your time

ghell
11-19-2008, 06:38 PM
My first idea was to build the form like I do with any contact form where the user fills in their details and then it gets emailed to the client, but I'm guessing this is not the correct way to do it.

If you have 7 steps and each step involves sending an email to the client, the client receiving an email and following a link, it will take a long time for them to fill in your form and most likely they will give up before finishing it (personally I give up before finishing 7 part forms even if they are all on 1 page. In fact, even if they are on 7 pages of paper)

Do I have to use a database?
No. Even if you want to persist data in some way, you don't have to use a database (you could use cookies or sessions and probably the view state)

Freon22
11-21-2008, 05:59 PM
ghell is right. We all have to fill out forms to get into sites but 7 pages is alot. So you can create 7 pages and when they fill out each page and click a button to go to the next page you can validate that they have filled out everything then do a Response.Redirect to the next page. Or you can use a MultiView control and do it all on one page.

Both ways are easy to do. Post again if you have any trouble on either.

QBall777
11-26-2008, 09:26 PM
Thanks for your input guys.

In the end I used the Wizard control as suggested earlier in the thread.

All my steps work fine and the user is presented at the end with a summary of their order. Once they are happy they click the finish button and the order is posted to my client.

The one thing I haven't tackled yet is:

In step 1 the user chooses 1 window from the radio button group. The windows come in different colours, however if the user chooses window D this window is only available in White or Black.

How do I go about coding the next step to disable the other colour options.

Any advice would be appreciated.

SouthwaterDave
11-30-2008, 05:48 PM
Create another step to ask for the colour. If window D is selected then grey out the unavailable colours when displaying this new step.

If you feel you must keep the window and the colour options in the same step then you could use javascript to grey out various colour options depending on which window is chosen. Don't forget though that javascript is only a convenience for the user; a hacker might select a green window D, so you must put appropriate validation in your .NET code.


Or you combine each window/colour option into single option, e.g.,

Window A (green)
Window A (blue)
Window D (black)
Window D (white)

QBall777
12-01-2008, 08:03 PM
Thanks for your thoughts SouthwaterDave.

The colour options were in the next step.
This is the code I used to enable certain colours.

All works well.

if (e.CurrentStepIndex == 0)
{
//allow white only
bool whiteOnly = (RadWindowL.Checked || RadWindowM.Checked);
//allow white and grain only
bool grainOnly = (RadWindowN.Checked || RadWindowO.Checked);
//do not allow grain
bool notgrain = (RadWindowP.Checked);

if (whiteOnly)
{
RadColourB.Enabled = !whiteOnly;
RadColourC.Enabled = !whiteOnly;
RadColourD.Enabled = !whiteOnly;
RadColourE.Enabled = !whiteOnly;
RadColourF.Enabled = !whiteOnly;
RadColourG.Enabled = !whiteOnly;
}
else if (grainOnly)
{
RadColourB.Enabled = !grainOnly;
RadColourC.Enabled = !grainOnly;
RadColourD.Enabled = !grainOnly;
RadColourE.Enabled = !grainOnly;

}
if (notgrain)
{

RadColourF.Enabled = !notgrain;
RadColourG.Enabled = !notgrain;

}

JygzIsHere
12-03-2008, 03:46 AM
Use Multiview, it contains different Views. So each step would be a view.