views:

18

answers:

2

I have a form(this form is a pop up) in which i have a JQGrid and a set of fields that i want to submit to the controller. The following is part of the form

<% using (Html.BeginForm("Index", "Role"))          
       {

    %>
    <tr>
        <td>
            <%= Html.Hidden("RoleId")%>
            <%= Html.Label("Priority:")%>
        </td>
        <td>
            <%= Html.TextBox("Priority")%>
        </td>
    </tr>
    <tr>
        <td>
            <%= Html.Label("System:")%>
        </td>
        <td>
            <%= Html.DropDownList("system", "system")%>
        </td>
    </tr>
    <tr>
        <td>
            <%= Html.Label("Client:")%>
        </td>
        <td>
            <%= Html.TextBox("Client")%>
            <%= Html.Hidden("state")%>
        </td>
    </tr>
    <tr>
        <td colspan="2">

            <input type="submit" name="CreateRequest" value="CreateRequest" onclick=AddRole();"" />
            <input type="button" id="btnCancel" name="Cancel" class="" value="Cancel" onclick="cancelAndRedirect();" />

        </td>
    </tr>
    <% } %>

The following is controller

public ActionResult Index(string RoleId, string state, string priority, string system, string client)
    {
        _roleEntity = new RoleEntity();
        List<SelectListItem> systemList;
        RequestModels _request = new RequestModels();

        _roleEntity.ValidFrom = DateTime.Now;
        _roleEntity.ValidTo = DateTime.Now;

        systemList = _request.GetAllSystems();
        ViewData[StringConstants.System] = systemList;
        if (RoleId == null && state == "Add")
        {
            ViewData[StringConstants.ErrorMessage] = "Please select a role";
        }
        else
        {
            ViewData[StringConstants.ErrorMessage] = string.Empty;
        }

        return View(_roleEntity);
    }

My Problem is, 1. when i click on CreateRequest button, a new window gets opened. The form does not post in the same window. 2. I am calling the Index method from the form as my attempts to call another custom method like CreateRequest failed with error like The view 'CreateReqeust' or its master could not be found. The following locations were searched: ~/Views/Role/CreateReqeust.aspx ...

Thanks and Regards, Muzammil Ahmed

A: 

There is nothing much in the AddRole method. I am just setting a value into a hidden field.

muzammil ahmed
A: 

Add this to the <head> section of the popup page:

<base target=_self>

This is a common ASP.NET issue, not specific to MVC.

Michael Haren