开发者

how to return different view from different method in controller in MVC

can anyone help me? senario is.. I have UserController(UC) and Browse View in MVC, In browse page I have three buttons and thats why i have written javascript to call perticular method in UC, now within UC I am sending data to Model (which is comming from View) and I am able to search from model also. ok..then after searched data is coming from model I am sending that data to view following code.

objUser = user.Search(1, "Ramesh", "", "", "", "", FMEnums.UserStatus.InActive);

        if (objUser.Count <= 0)
        {
            ViewData["Message"] = "Unauthorised";

            return View("Browse", objUser);
        }
        else
        {

           return View("Browse", objUser);
        }



         and in View( that is  Browse.aspx) by giving

( <%@ Page Title="Max 2.0" Language="C#" MasterPageFile="~/Views/Shared/Master.Master" Inherits="System.Web.Mvc.ViewPage>"%> )

at the start of my Browse page I am accepting that data. ok...

        and rendering开发者_JS百科 that incoming data by following code..

                                                 <%if(Model != null){ %>
                                            <tr>
                                                <td class="td_bgcolor"> User Name  </td>
                                                <td class="td_bgcolor"> First Name </td>
                                                <td class="td_bgcolor"> Last Name  </td>
                                                <td class="td_bgcolor"> e-mail     </td>
                                                <td class="td_bgcolor"> Role       </td>
                                                <td class="td_bgcolor"> Staus      </td>
                                                <td class="td_bgcolor">            </td>
                                            </tr>
                                                <% foreach( var user in  Model)%>
                                                <%{ %>
                                                <tr>
                                                    <td><a href="#"><%=user.UserName %></a></td>
                                                    <td><%=user.FirstName %></td>
                                                    <td><%=user.LastName %></td>
                                                    <td><%=user.Email %></td>
                                                    <td><%=user.Status %></td>
                                                    <td><%=user.Roles %></td>
                                                    <td>
                                                          <a href="#">Delete</a>
                                                    </td>
                                               </tr>
                                                  <%} %>
                                           <%} %>

Butt..

now the problem is...it is successfully debugging but my Browse page is not comming with data instead browser is rendering "User/Search" page which is not even in the project.

plzzzzzzz can any one have solution?


It's hard to say without knowing what you have in your routes. Especially if your getting a page that's not in your project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜