开发者

ASP.Net MVC 3 Controller Action and Open New Window

开发者 https://www.devze.com 2023-04-13 06:04 出处:网络
i have a controller and an action. this action is to save data into database. and now, i want when i submit a button, my controller do an action and open new window.

i have a controller and an action. this action is to save data into database. and now, i want when i submit a button, my controller do an action and open new window.

public ActionResult New(FormCollection collection)
    {

       data.Population_Code = collection["Countrys[0].CountryCode"];
       data.Population_Desc = collection["Countrys[0].CountryDesc"];
       data.Population_Grouping = collection["Countrys[0].CountryGroup"];
       data.Population_Type = "CNTRY";
       data.Population_Redudant = "N";
       data.Population_Modified_At = officeCode.User_Office.ToString();
       db.SaveChanges();

      //example for new window
      //windo开发者_如何学JAVAw.open('/Report/New.aspx')

      return RedirectToAction("index");
    }

so my controller do an action and open a new window.

anyone can help me ?

thanks


Technically, this can be done by returning javascript that will open the new window.

However, most browsers will kill a new window called in this manner (i.e. popup blocker).

You would be better off, if possible, by opening the link to your action in a new window from the start;

@Html.ActionLink("New report", "New", "Report", null, new {target = "_blank"})

Edit

I can see from your action, that it is probably a form that creates the report; you can also use the attribute target='_blank' on a form as well.

0

精彩评论

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