Click here to Skip to main content
15,845,436 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Procedure or function 'sp_getchech' expects parameter '@ID', which was not supplied Pin
Richard Deeming9-Aug-17 9:14
mveRichard Deeming9-Aug-17 9:14 
GeneralRe: Procedure or function 'sp_getchech' expects parameter '@ID', which was not supplied (SOLVED) Pin
samflex9-Aug-17 15:54
samflex9-Aug-17 15:54 
QuestionWhat is better solutions for complex application and databases Pin
Lakhpat-Singh8-Aug-17 8:22
Lakhpat-Singh8-Aug-17 8:22 
AnswerRe: What is better solutions for complex application and databases Pin
F-ES Sitecore9-Aug-17 1:00
professionalF-ES Sitecore9-Aug-17 1:00 
QuestionGetting Route Values in Controller Pin
Farhad Eft7-Aug-17 8:20
Farhad Eft7-Aug-17 8:20 
AnswerRe: Getting Route Values in Controller Pin
Richard Deeming7-Aug-17 11:21
mveRichard Deeming7-Aug-17 11:21 
GeneralRe: Getting Route Values in Controller Pin
Farhad Eft7-Aug-17 14:19
Farhad Eft7-Aug-17 14:19 
Questiontrying to call a WebApi method along with new Page when button clicked using jQuery Pin
indian14331-Jul-17 16:26
indian14331-Jul-17 16:26 
Hi,

I am trying to call a Web Api method (/BSCSecurityAddressBookWeb/api/MultiJobChangeApi/Get) when a button clicked, it has to load a new page (MultiJobChange)
(from Employee page to MultiJobChange)
and in MultiJobChange.js file I have written code for calling the Web Api,
MultiJobChange.cshtml page is loading by calling its Controller using the call window.open('/BSCSecurityAddressBookWeb/MultiJobChange/', '_self', false);,

MultiJobChangeController Index method returns View, up loading of the cshtml page its working properly, but the call to /BSCSecurityAddressBookWeb/api/MultiJobChangeApi/Get is not going.

Can anybody please help me in this regards, I am new to MVC, I am able to move to the new Page or Controller from Employee Page as Employee Page (or Controller is starting one) but not able to call the Web Api method from there even though I am seeing all js files loaded in resources in browser debugger, but still the Web Api call is not making through. Any help would be every supportive thanks in advance.

My Code looks as below:
code in MultiJobChange.js file

MultiJobChange = {
    loadMultiJobChange: function (employeeID) {
        $.get("/BSCSecurityAddressBookWeb/api/MultiJobChangeApi/Get").then(function (data) {

<pre>
        var list = $("#ddlEmployees");
        var selectedValue = list.val();

        list.empty();

        $.each(data, function (index, userList) {
            $("<option>").attr("value", userList.EmployeeID).text(applicationgroup.LastName).appendTo(list);
        }); 

    $("#btnClearList").click(function (event) {
        $("#lbxEmployees").empty();
    });

    $("#btnRemoveEmployee").click(function (event) {
        $("#lbxEmployees option:selected").remove();
    });
}

};

code in Employee.js file

loadEmployee: function (employeeID) {
$.get("/BSCSecurityAddressBookWeb/api/EmployeeAPI/Get").then(function (data) {
    var list = $("#ddlApplicationGroup");
    var selectedValue = list.val();

    list.empty();

    $.each(data.ApplicationGroups, function (index, applicationgroup) {
        $("<option>").attr("value", applicationgroup.ApplicationGroupID).text(applicationgroup.ApplicationGroupName).appendTo(list);
    });

    if ((selectedValue == null) || (selectedValue == undefined)) {
        list.prepend("<option value='-1' selected='selected'>Select value</option>");
        if ((list[0] != undefined) && (list[0] != null))
            list[0].selectedIndex = 0;
    }
    else {
        list.val(selectedValue);
    }

    var list = $("#ddlReportPack");
    var selectedValue = list.val();

    list.empty();

    $.each(data.ReportPacks, function (index, reportpack) {
        $("<option>").attr("value", reportpack.ReportPackID).text(reportpack.ReportPackName).appendTo(list);
    });

    if ((selectedValue == null) || (selectedValue == undefined)) {
        list.prepend("<option value='-1' selected='selected'>Select value</option>");
        if ((list[0] != undefined) && (list[0] != null))
            list[0].selectedIndex = 0;
    }
    else {
        list.val(selectedValue);
    }

});

}

code in Layout.js file

$(function () {
$("#btnEmployee").click(function (event) {
Employee.loadEmployee();
window.open('/BSCSecurityAddressBookWeb/Employee/', '_self', false);

});
$("#btnMultiJobChange").click(function (event) {
    MultiJobChange.loadMultiJobChange();
    window.open('/BSCSecurityAddressBookWeb/MultiJobChange/', '_self', false);        
});

});

Code in MultiJobChange/Index.js file

function LoadMultiJobChange() {
MultiJobChange.loadMultiJobChange();

};

$(function () {
LoadMultiJobChange();
});

Code in Employee/Index.js file


function LoadEmployee() {
Employee.loadEmployee();
};

$(function () {
LoadEmployee();
});

Controller methods:

public class MultiJobChangeApiController : ApiController

{
// GET: api/MultiJobChangeApi
public List<userlist> Get()
{
dynamic model = null;
using (AppDevSecEntities ctx = new AppDevSecEntities())
{
var temp = ctx.UserLists.AsNoTracking().OrderByDescending(x => x.LastName);
if (temp != null)
model = temp.ToList<userlist>();
}
return model;
}
}

public class MultiJobChangeController : Controller
{
// GET: MultiJobChange
public ActionResult Index()
{
using (AppDevSecEntities ctx = new AppDevSecEntities())
{
BSCCrystalReportsViewerEntities ctx2 = new BSCCrystalReportsViewerEntities();

}
return View();
}
}


Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."
AnswerRe: trying to call a WebApi method along with new Page when button clicked using jQuery Pin
Richard Deeming1-Aug-17 1:50
mveRichard Deeming1-Aug-17 1:50 
GeneralRe: trying to call a WebApi method along with new Page when button clicked using jQuery Pin
indian1431-Aug-17 8:01
indian1431-Aug-17 8:01 
GeneralRe: trying to call a WebApi method along with new Page when button clicked using jQuery Pin
Richard Deeming1-Aug-17 8:24
mveRichard Deeming1-Aug-17 8:24 
GeneralRe: trying to call a WebApi method along with new Page when button clicked using jQuery Pin
indian1431-Aug-17 14:23
indian1431-Aug-17 14:23 
QuestionI would like to develope new project from scratch. I would like to use ASP.NET MVC 5.0, EntityFramework and SQL Server. Pin
Lad Kunal30-Jul-17 21:14
Lad Kunal30-Jul-17 21:14 
AnswerRe: I would like to develope new project from scratch. I would like to use ASP.NET MVC 5.0, EntityFramework and SQL Server. Pin
Richard MacCutchan30-Jul-17 21:42
mveRichard MacCutchan30-Jul-17 21:42 
AnswerRe: I would like to develope new project from scratch. I would like to use ASP.NET MVC 5.0, EntityFramework and SQL Server. Pin
indian1432-Aug-17 7:57
indian1432-Aug-17 7:57 
QuestionError message: The operation cannot be completed because the DbContext has been disposed Pin
indian14327-Jul-17 12:39
indian14327-Jul-17 12:39 
AnswerRe: Error message: The operation cannot be completed because the DbContext has been disposed Pin
Richard Deeming28-Jul-17 2:31
mveRichard Deeming28-Jul-17 2:31 
AnswerRe: Error message: The operation cannot be completed because the DbContext has been disposed Pin
Nathan Minier28-Jul-17 2:36
professionalNathan Minier28-Jul-17 2:36 
QuestionUnable to use RequiredValidator control to validate RadioButtonList in Repeater? Pin
samflex26-Jul-17 15:25
samflex26-Jul-17 15:25 
AnswerRe: Unable to use RequiredValidator control to validate RadioButtonList in Repeater? Pin
F-ES Sitecore26-Jul-17 23:45
professionalF-ES Sitecore26-Jul-17 23:45 
GeneralRe: Unable to use RequiredValidator control to validate RadioButtonList in Repeater? (SOLVE) Pin
samflex27-Jul-17 4:05
samflex27-Jul-17 4:05 
QuestionFew questions about web api versioning in core Pin
Mou_kol26-Jul-17 2:38
Mou_kol26-Jul-17 2:38 
QuestionEnable/Disable div based on RadiobuttonList Pin
samflex25-Jul-17 6:41
samflex25-Jul-17 6:41 
AnswerRe: Enable/Disable div based on RadiobuttonList Pin
F-ES Sitecore25-Jul-17 7:30
professionalF-ES Sitecore25-Jul-17 7:30 
AnswerRe: Enable/Disable div based on RadiobuttonList Pin
Richard Deeming25-Jul-17 7:50
mveRichard Deeming25-Jul-17 7:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.