Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am in a confusion that I have a registration form and in that I have given a check box. When the checkbox is true or checked the flow must pass to a perticular controller or else if the checkbox is unchecked the flow of program must move to another controller .
so My problem is that is it possible to give condition in mvc sitemapnode? Because this is the admin side work and I dont know how toachieve that.
Can anyone please help me find a solution

What I have tried:

I ahve searched and only find that the it can give the visibility provider and not the condition
Posted
Updated 5-Jun-17 2:07am
Comments
David_Wimbley 29-May-17 22:18pm    
You may want to rethink how you are structuring your application. Switching controllers (and thus, actions) seems like a round about way when you can probably control that logic in one controller/action and its relevant model.

The other alternative would be to handle this in javascript and basically just say

if(checkbox.prop("checked"))
{
$.post("/send/data/to/controller/A");
}
else
{
$.post("/send/data/to/controller/B");
}

Where you send your data to "controller" (to use your terms) A if it is checked and then send it to "controller B" if it is not checked.

1 solution

Hello:
I'm not absolutelly sure about what do you want. I supose that in the controller that recibes your registration form (for instance RegistrationController) you want to redirect to two Action (said A and B) depending on the state of a check in the form.

In that case you can do something like this:
public class RegistrationController:Controller
{
...
   public ActionResult ProcessForm(ModelX data)
   {
     ...
     if (the_user_have_made_clik_in_x)
        return RedirectToActionPermanent("A", "Registration", data);
        //or
        //return RedirectToActionPermanent("A", "OtherController", data);
     else
        return return RedirectToActionPermanent("B", "Registration", data);       
        //or
        //return RedirectToActionPermanent("B", "OtherController", data);
   }


   public ActionResult A(ModelX data)
   {
   ...//process here to case 1
   }

   public ActionResult B(ModelX data)
   {
   ... //process here to case 2
   }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900