open view in new tab with ajax parameter c# mvc

open view in new tab mvc jquery
open new tab on button click in mvc
open partial view in new tab in mvc
mvc actionlink open in new window
redirect to new tab in mvc controller
how to open pdf file in new tab in mvc using c#
url action in new tab mvc
blazor open new tab

Please help I've tried everything I could, I want to open new view with parameter but in a new tab, and my view url is same as the ajax url I have. I am so confused, still new to this.

this is my javascript code:

 $(document).on('click', "a.clsApproval", function (e) {
        var vData = JSON.parse($(this).attr('dataTake'));
        var vCode = vData.MUIGCode;
        var vID = vData.Id;

            url: '/ApprovalMapPerUserEpr/Index',
            data: { Id: vID, MUIGCode: vCode },
            method: 'POST',
            success: function (mdl)
                var url = '@Url.Action("Index", "ApprovalMapPerUserEpr")';

            error: function (mdl)

this is my controller:

    public ActionResult Index(int Id, string MUIGCode)
        if (Session["role_id"] == null)
            return RedirectToAction("Login", "Home");
            var cnn = new SqlConnection(SQLCon);
            var cmmd = new SqlCommand();
            var query = "";

                query = "SELECT[dbo].[M_UIGH].[MUIGCode] \n " +
                            ",[dbo].[M_UIGH].[CreateDate] \n " +
                            ",[dbo].[M_UIGH].[CompanyID] \n " +
                            ",[dbo].[M_UIGH].[CompanyName] \n " +
                            ",[dbo].[M_UIGH].[BranchID] \n " +
                            ",[dbo].[M_UIGH].[BranchName] \n " +
                            ",[dbo].[M_UIGH].[UserID] \n " +
                            ",[dbo].[M_UIGH].[UserName] \n " +
                            ",[dbo].[M_UIGH].[UserDept] \n " +
                            ",[dbo].[M_UIGD].[Id] \n " +
                            ",[dbo].[M_UIGD].[CostCenter] \n " +
                            ",[dbo].[M_UIGD].[CCName] \n " +
                            ",[dbo].[M_UIGD].[CCLevel] \n " +
                            ",[dbo].[M_UIGD].[ItemGroupCod] \n " +
                            ",[dbo].[M_UIGD].[ItemGroupName] \n " +
                            ",[dbo].[M_UIGD].[CoaItemGroup] \n " +
                        "FROM [dbo].[M_UIGD] \n " +
                        "INNER JOIN [dbo].[M_UIGH] ON [dbo].[M_UIGH].[MUIGCode] = [dbo].[M_UIGD].[MUIGCode] \n " +
                        "WHERE [dbo].[M_UIGD].[MUIGCode] = '" + MUIGCode + "' " +
                            "AND [dbo].[M_UIGD].[Id] =  '" + Id + "' ";

                cmmd = new SqlCommand(query, cnn);
                SqlDataReader dreader = cmmd.ExecuteReader();
                MapingUIGD map = new MapingUIGD();

                if (dreader.Read())
                    map.MUIGCode = dreader.GetString(dreader.GetOrdinal("MUIGCode"));
                    map.Id = dreader.GetInt32(dreader.GetOrdinal("Id"));
                    map.CompanyID = dreader.GetString(dreader.GetOrdinal("CompanyID"));
                    map.CompanyName = dreader.GetString(dreader.GetOrdinal("CompanyName"));
                    map.BranchID = dreader.GetString(dreader.GetOrdinal("BranchID"));
                    map.BranchName = dreader.GetString(dreader.GetOrdinal("BranchName"));
                    map.UserID = dreader.GetString(dreader.GetOrdinal("UserID")); 
                    map.UserName = dreader.GetString(dreader.GetOrdinal("UserName")); 
                    map.UserDept = dreader.GetString(dreader.GetOrdinal("UserDept")); 
                    map.costCenter = dreader.GetString(dreader.GetOrdinal("CostCenter")); 
                    map.costName = dreader.GetString(dreader.GetOrdinal("CCName")); 
                    map.costLevel = Convert.ToInt32(dreader["CCLevel"]);
                    map.itemGroupCode = dreader.GetString(dreader.GetOrdinal("ItemGroupCod")); 
                    map.itemGroupName = dreader.GetString(dreader.GetOrdinal("ItemGroupName")); 
                    map.coa = dreader.GetString(dreader.GetOrdinal("CoaItemGroup")); 

                ViewBag.Title = "Approval Mapping Per User (ePR)";
                return View(map);
            catch (Exception e)

this is my form, the one which should open new tab is link approval setting, it should open the approval view in new tab.

Instead of using an ajax call you can use Html.ActionLink like this:

@Html.ActionLink("linkText", "Action", new {controller="Controller"}, new {target="_blank"})

This will call your controller action directly and open the result in a new tab.

How to open a razor view in a new window (or a new tab)?, In my mvc web app, I have a webgrid with the code as this: Html.ActionLink( GlobalRes. function, and through Ajax to achieve the modification and saving of data. This codes open the new tab window, but I got error message below: Methods in C# can be overloaded which means the same method� But if you insist on rendering the data on the page, you don't need to use Ajax, just redirect the page to the URL: window.location = "@Url.Action("Calculate", "Home")"; Or you could open a new window, write the content in the new window with js:

If you wanted to use the answer that @jpishko suggested you would need to add the parameters like this

    linkText: "Click Me",
    actionName: "Index",
    controllerName: "ApprovalMapPerUserEpr",
    routeValues: new {
        Id = "3",
        MUIGCode = "test"
    htmlAttributes: new
        target = "_blank"

Or you could add a form to your html to look something like this

<form method="post" action="@Url.Action("Index", "ApprovalMapPerUserEpr")" target="_blank">
    <input name="Id" value="3"/>
    <input name="MUIGCode" value="test" />
    <input type="submit" value="Click Me" />

and then have the values for Id and MUIGCode be whatever you need.

ajax open new tab with post Code Example, Get code examples like "ajax open new tab with post" instantly right from your js � '%s=%s' % (k, v) for k, v in params.items(), ^ SyntaxError: Generator file into a Datagridview in windows form using C# � bindbidirectional vue js display json data in html table using javascript dynamically � display none� While this is attractive in some applications, adding AJAX functionality adds an additional layer of complexity that ends up getting some new (and old) developers stuck. Furthermore, .NET has some quirks that aren’t really obvious. Let’s take a look at how to make a jQuery AJAX call to an MVC Controller with parameters.

To open a view in a new tab , you could use html attribute target ="_blank" Either use this in html or add in @Html.ActionLink .

Ajax.ActionLink and Html.ActionLink in MVC, Html.ActionLink creates a hyperlink on a view page and the user clicks it Razor is smart enough to assume the first param is link text and the second list of countries, an async result will be opened on the new browser tab. Calling URL from Controller: return RedirectToAction("Edit", "Home"); Calling Action Method from View using HTML Button or Image: When creating a link to a controller action in ASP.NET MVC, using the generic ActionLink method is preferable, because it allows for strongly typed links that are refactoring friendly.

Open Page (View) in New Tab (Window) on Button Click in ASP.Net , Net MVC Razor. Button cannot be used to open Page (View) in New Tab ( Window) and hence using JavaScript's function, the� In this post, we will learn about how to open PDF or other files in a new tab using C#. For this example, first we need to return a file from MVC Controller then open the file in a new tab from view. For this, I will set return type "FileResult" from MVC controller and return "File" with a byte Array of the file and its content type. mvc 4 Open mvc view in new window from controller?, IsValid))'; // checks that model is valid if (isValid == 'true') { //open new tab or window - according to configs of 1) Call your controller from a view by ajax. Another major advance to JavaScript and Ajax is the JavaScript object library called jQuery, which is the free, open-source software. It is a wrapper for JavaScript. jQuery is used to write the JavaScript to navigate and manipulate a page and make asynchronous Ajax callbacks.

Open mvc view in new window from controller, Is there any way to open a view from a controller action in a new window? I like to call an MVC action by passing parameters as a Model and I want to show a new window. you can not use directly to a view , but use a , for example, Ajax. How To Open PDF File In New Tab In MVC Using C#, For this example, first we� The View() method doesn't make new requests, it just renders the view without changing URLs in the browser's address bar. The RedirectToAction() method makes new requests and URL in the browser's address bar is updated with the generated URL by MVC.

  • i'm sorry, i've tried that one. my problem is that url on success function ajax is same with url ajax.
  • @PutriAlvionia thanks for clarification, I updated my answer
  • how about the parameters that i give in ajax data? i used ajax because i have to send 2 parameters, id and code.