FAQ Database Discussion Community


Why PartialView cannot reload with Ajax in MVC

ajax,asp.net-mvc,asp.net-ajax,asp.net-mvc-partialview,ajax.beginform
I use a popup window to create a new record and I render a view inside the window. In addition to this, I call a partialview in this view according to the selectedindex of a combobox in it. I can successfully post the form to the Controller and return it...

How to set active to the class

javascript,asp.net-mvc,c#-4.0,asp.net-ajax
I am changing the language by changeCulture method which is ; public ActionResult ChangeCulture(Culture lang, string returnUrl) { if (returnUrl.Length >= 3) returnUrl = returnUrl.Substring(3); return Redirect("/" + lang.ToString() + returnUrl); } and here is the html part ; <li class="currency-EUR"> <a href="@Url.Action("ChangeCulture", "Home", new { lang = (int)SkycapGaming.Culture.Tr, returnUrl...

CS0120: An object reference is required for the non-static field, method, or property '_Default.txtEditValue'

c#,asp.net,asp.net-ajax
When I click a button it gets the value of that button(Id) and pass it to the code behind page ----Ajax Code------ .ajax({ type: "POST", url: "CS.aspx/Edit", data: "{'dt1':'" + dt1 +"'}", contentType: "application/json; charset=utf-8", dataType:"json", success: function(result) { alert(result.d); } }); Edit is the method that i used in...

AJAX Call in ASP.NET not Firing Server Side Method

jquery,asp.net,ajax,asp.net-ajax,webmethod
I'm developing on asp.net webforms and can't solve an issue while making an ajax call from client side. I got the client side script: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $.ajax({ type: "GET", url: "Default.aspx/getnewmails", data: {}, dataType: "html", success: function (str) { $("#div2").html(str); } }); }); </script>...

How to alert $.ajax get data which contain date

jquery,ajax,json,datetime,asp.net-ajax
this is my controller action. holiDays variable contains array of DateTime like(21/03/2015 12:00:00 AM) which I passed by Json to the view: [HttpGet] public JsonResult GetHolydays() { var holiDays = DbFactory.Db.YearHolydays.ToList(); return Json(new {con = holiDay},JsonRequestBehavior.AllowGet); } and this is my jquery codes,which gets data via ajax request: <script> scheduler.attachEvent("onSchedulerReady",...

What are techniques in ASP for communication from usercontrol to parent page?

c#,asp.net,events,user-controls,asp.net-ajax
I have having some trouble with communication from a usercontrol to the main page. The order in which events are raised means that the action on the user control occurs too late in the post back to have an effect on the main page. For example, I have a button...

MVC.NET, JQuery - How to submit a form that is made up of a JQuery datatable with rows that contain checkboxes and text inputs?

jquery,ajax,asp.net-mvc,asp.net-mvc-4,asp.net-ajax
I have a jquery datatable that has multiple rows that contain checkboxes and text input fields. My object is to select all the rows that have the checkboxes checked and submit them via ajax. I am able to get the "id" attribute of all the checkboxes that are checked, but...

AJAX error - Indirect reference is being made to assembly

ajax,asp.net-ajax,ajaxcontroltoolkit
I'm upgrading a project from the v2.0 framework to the v4.5.1 framework and I'm getting the following error... Indirect reference is being made to assembly System.Web.Extensions version 4.0.0.0, which contains 'AjaxControlToolkit.MaskedEditExtender'. This Project references a prior version of System.Web.Extensions version 1.0.61025.0. To use 'AjaxControlToolkit.MaskedEditExtender', you must replace the reference to...

ASP.NET MVC “Editable” ListBox

asp.net-mvc,model-view-controller,asp.net-ajax
I am using ASP.NET MVC platform. In my controller I am creating ViewBag that selects i.e. all the names from the database. I have a @Html.listbox in my view and I am using select2() ajax function which is used for suggesting as i type in listbox. In example if i...

("NetworkError: 401 Unauthorized) Calling code behind method from JavaScript

javascript,asp.net,ajax,asp.net-ajax
I am trying to call code behind method from JS but it gives me this error NetworkError: 401 Unauthorized Here is the code behind method [System.Web.Services.WebMethod] public string ExtractToPDF(string FSID) { return FSID; } and here is the JS Function function extractFile(FSID) { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url:...

Client Side binding Telerik RadListView not working, what is missing?

telerik,asp.net-ajax,client-side-data,radlistview
I can seem to get client-side binding to work (after 2 days) using Telerik controls. AM I not providing the right kind of fake value/pair data? Not finding the control ID properly? What needs to be done to properly bind data to Telerik RadListView from the client side? <%@ Page...

Asp.net mvc 4 jquery ajax request return internal server error

jquery,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,asp.net-ajax
I tried to establish ajax request to asp.net mvc controller , but it give me internal server error // My Products Controller [HttpPost] public ActionResult FilterCategeory(int prodID) { var categs = new Categ() {PROD_ID=prodID }.Search(); return Json(categs); } //My ajax request $("#categs").empty(); var prm = $("#prods").val(); $.ajax({ type: "POST", url:...

Pass a value of textbox from view to controller through hyperlink in MVC ASP.NET

c#,jquery,asp.net-mvc,asp.net-mvc-4,asp.net-ajax
In View- <input type="text" hidden="hidden" id= "nameString" name="nameString" value="xyz" /> @Html.ActionLink("Save", "HomePage", "ControllerName", new { nameString = "/* Value from above input here.*/" }) In this case I want to pass "xyz" through this hyperlink. Can't use Get or POST methods to pass this value. This HomePage view is not...

Ajax call not reaching controller method

javascript,jquery,ajax,asp.net-mvc,asp.net-ajax
Yes, there are a whole bunch of posts with similar questions. I've tried to follow the answers in them, but my ajax call still isn't reaching the controller method. controller (SalesController.cs): [HttpGet] public JsonResult fillVarietiesSelect(int species_id) { String[] alist = {"a","b","c"}; return Json(alist, JsonRequestBehavior.AllowGet); } javascript: $('#species-select').on('change', function () {...

JSON Invalide primitive

c#,jquery,ajax,json,asp.net-ajax
I want to passing my number of seat to TryJSIN.aspx in function test(). but I have error, when I use type 'GET' then I have error "Invalid JSON primitive: 1-9." 1-9 is noSeat value. but when I change to 'POST' I have error An attempt was made to call the...

asp.net MVC ajax does post back instead of render partial view in my div

jquery,ajax,asp.net-mvc,asp.net-mvc-4,asp.net-ajax
I have this code written in my index.cshtml @Ajax.ActionLink("First", "First", new AjaxOptions() { HttpMethod = "GET", UpdateTargetId = "partialstest", InsertionMode = InsertionMode.Replace }) @Ajax.ActionLink("Second", "Second", new AjaxOptions() { HttpMethod = "GET", UpdateTargetId = "partialstest", InsertionMode = InsertionMode.Replace }) <div id="partialstest" style="width: 500px; height:500px; border:1px solid red;"> </div> <script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>...

How to call sub onchange of a dropdownlist while using AJAX?

asp.net,vb.net,asp.net-ajax,ajax.net
So, I know how to call a method onclick of a button using ajax, but I'd like to do the same when a user selects something new on a dropdownlist. I'll show code for what I've tried below: <asp:UpdatePanel ID="pnlHelloWorld" runat="server"> <ContentTemplate> <div style="height: auto; overflow: auto; max-height:750px; width:100%;"> <asp:DropDownList...

ASP.NET mvc Ajax Helper DropDownListFor send selected item value as parameter to controller

asp.net-mvc-4,asp.net-ajax,value,dropdownlistfor,ajaxhelper
Problem I want my Ajax form to pass the value of the selected DropDownListFor to the controller but I can't figure out why the controller is not taking any value. I am working with ASP.NET MVC and I would like to stick with the helper functions as much as I...

Why my ajax call do not work?

ajax,asp.net-mvc,asp.net-mvc-5,asp.net-ajax
I am not able to detect why my ajax call do not work. I am trying to read the contents of text file but it do not work, The problem is control never go to .done(function(data)) function makeCustomerTree() { // debugger alert('customertree'); $.ajax( { url:"~/bootstrap/js/LiveMap/Ajax/JsonStringCarryingData/customer-tree-json.txt", data: {}, type: "GET" }).done(function...

Upgrade/Convert AJAX.NET controls in a web site converted to Visual Studio 2013 from VS 2005

.net,visual-studio-2013,asp.net-ajax,upgrade
Our client wants to upgrade an existing web application that uses AJAX.NET and Framework 2. They want the application converted to Visual Studio 2013 from Visual Studio 2005, so that it uses Framework 4.5. My question is: what about the AJAX.NET controls? How can they be migrated? I suppose the...

Ajaxcontrol Toolkit CascadingDropdownList populated event trouble

asp.net,.net-3.5,asp.net-ajax,ajaxcontroltoolkit
I've got 2 CascadingDropdownList, Application and Role. When Application changes Role is populated. I do a partial rendering of a UpdatePanel with User List when Application or Role changes. The problem is that when Application changes the value of Role sent in the POST to render UpdatePanel is the old...

MVC5 Partial View redirects instead of updating DIV

jquery,asp.net,asp.net-mvc-5,asp.net-ajax
I found this problem more than once on SO, but I found no solution that works for me. I have a view: <div id="profpics"> @Html.Partial("_ProfileImagesPartial", Model.ProfileImages) @using (Ajax.BeginForm("UploadImage", "ProfileImages", new AjaxOptions { UpdateTargetId = "profpics", HttpMethod = "GET" })) { @Html.AntiForgeryToken() <input type="file" name="file" id="imgInp" /> <img id="blah" src="#" alt="your...

How to use Html.Raw(Json.Encode(Model)) properly?

jquery,ajax,json,asp.net-mvc,asp.net-ajax
I'm trying to Encode my MVC Model with the following code but the alert message gives me a null value. I'm not sure why it's giving me a null value because this is a create form. I'm trying to create a model from this and my html Code has the...

Why I get null values in post ajax call?

asp.net-ajax
Here is my Javascript block: <script> var u; var p; function login() { u = $("#userNameID").val(); p = $("#passwordID").val(); $.ajax({ type: "POST", url: "Login.aspx", data: { username: u, password: p}, success: function () { alert("success!!!") } }); } </script> At server side after the post call I try to retrive...

How to download a file through ajax request in asp.net MVC 4

jquery,json,asp.net-mvc-4,asp.net-ajax
Below is my code : public ActionResult DownloadAttachment(student st) { var file = db.EmailAttachmentReceived.FirstOrDefault(x => x.LisaId == st.Lisaid); byte[] fileBytes = System.IO.File.ReadAllBytes(file.Filepath); return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, file.Filename); } This is the script which i'm using $(function () { $("#DownloadAttachment").click(function () { $.ajax( { url: '@Url.Action("DownloadAttachment", "PostDetail")', contentType: 'application/json; charset=utf-8', datatype: 'json',...

Retrieve Custom exception message from service layer in ajax call

jquery,asp.net-mvc-5,asp.net-ajax,servicestack
I have developed my application in ASP.net MVC5 using ServiceStack framework. In my app, on button click, I make ajax server call which returns data. this.LoadData = function(){ $.ajax({ url: '@Url.Action("SearchCustomer", "Customer")', cache: false, type: 'GET', contentType: 'application/json', data: { 'IndexNo': this.IndexNo }, success: function (result) { }, error: function...

Paypal Payflow Transparent Redirect, SecureToken with AJAX?

ajax,paypal,asp.net-ajax,token,payflowpro
I'm working on a C# VS2012 Framework 4.5 MVC application that is trying to become PCI compliant using Payflow Pro (https://pilot-payflowpro.paypal.com). We've been using PayflowPro for years, and this is what I have to use. From my reading it seems that I should use the Transparent Redirect so I'm not...

How to retrieve Ajax header in this asp.NET web api method?

c#,asp.net,asp.net-web-api,header,asp.net-ajax
[Route("api/test")] public IEnumerable<Tests> GetTests() { //Retrieve ajax header here?? return ClassTestfuntions.Testmethod(); } I have this asp.net web api method that i use to GET a list of rows from my db, im now also sending an header to this method within my ajax http get call but im not...

Change text in UpdatePanel

c#,asp.net,asp.net-ajax,updatepanel
I am new with ASP.NET. This is my code: <asp:UpdatePanel runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Button Text="Change" runat="server" ID="BtnChangeText" OnClick="BtnChangeText_OnClick"/> <asp:Label runat="server" ID="LblTest" Text="Change me!"></asp:Label> </ContentTemplate> </asp:UpdatePanel> This is my server code: protected void BtnChangeText_OnClick(object sender, EventArgs e) { LblTest.Text = "Hello World!"; } Why does it not work?. How can I...

serverside function/method calling from client side in asp.net

javascript,vb.net,asp.net-ajax
i want to call server side function from clientside in vb.net. Which is the better way to do this And Why? 1.With the use of ajax or 2.javascript(pagemethods.methodname(arguments))...

Success function is not getting invoked in ajax GET method

javascript,jquery,ajax,asp.net-ajax
In this code I am facing a problem in the success function. I tried a lot but it is going to the error function. The #action-button calls the JavaScript Method. <button id="action-button">Click me to load info!</button> <div id="info"></div> <small> Demo created by <a href="https://twitter.com">Twitter</a> </small> $('#action-button').click(function() { $.ajax({ url: 'sampleurl',...

Pass data from javascript to MVC controller

javascript,asp.net-mvc,asp.net-ajax,vis.js
I have a tree hierarchy which I have built using Vis.js library. My project is in asp.net MVC. Every node in the tree has an id. The requirement is that when I click on any of the node, the id should be passed to a controller and the view corresponding...

Validating Existing Code from Database in Ajax Call

c#,jquery,ajax,asp.net-mvc-4,asp.net-ajax
I am not getting why my code is not working. I am trying to validate a code by calling a function in controller. if this code already exists i simply sent 'failed' text and then i want the form to stop its submission. but this does not work. even i...

Function not defined error while using asp.net ajax

javascript,c#,asp.net,ajax,asp.net-ajax
i am trying to call a web service through asp.net ajax by the following code namespace MCTS70515AJAX { public static class HR { public static int GetEmployeeCount(string department) { int count = 0; switch (department) { case "Sales": count = 10; break; case "Engineering": count = 28; break; case "Marketing":...

DataTables ajax requires explicit json collection name for the returned datasource?

datatables,asp.net-ajax,datasource
I recently ran into a problem when implementing the ajax functionality of jquery DataTables. Until I actually gave my json object collection an explicit name I couldn't get anything to display. Shouldn't there be a default data source if nothing named is returned? Client Side control setup (includes hidden field...