Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

ajax sending data to controller

$
0
0

Hi i'm new to this and i need some help. Basically on a click of  abutton i would get some values from the view and post it to the controller to be updated.

There are two methods that i've seen which is using ajax.beginform and also the ajax action link.

My problem is using the begin form the data gets to the controller but the data is not updated even when i specify a java function onbegin.

My problem with the actionlink is that it does not reach the controller.

//This reachest the controller


<% using (Ajax.BeginForm("UpdateFlags", null,

new RouteValueDictionary(new { Model.ParentId, Model.Page }),
new AjaxOptions() { UpdateTargetId = "testflag123", OnBegin = "flagtest", InsertionMode = InsertionMode.InsertAfter},
new Dictionary<string, object> { { "data-ajax-mode", "CALLBACK" }, { "data-ajax-update-callback", "updateUploader" }, { "id", "testflag123" } }))
{%>



<div id="testflag123">



<input type="hidden" id="documentId" />
<input type="hidden" id="flags[0]" />
<input type="hidden" id="flags[1]" />


<input type="hidden" name="flagsmodelId" value="16"/>
<input type="hidden" name="flagsmodelFlagIds[0]" value="4"/>
<input type="hidden" name="flagsmodelFlagIds[1]" value="5"/>


</div>

<input type="submit" value="submit"/>

<% } %>

<script type="text/javascript">


function flagtest() {
debugger;
document.getElementById('documentId').value = 13;
document.getElementById('flags[0]').value = "13";
document.getElementById('flags[1]').value = "12";
var test = document.getElementById('flags[1]').value;
alert(test);
};

</script>

this doesnt reach the controller

$('.saveFlag').click(function () {

var Id = {
Id: 113,

};

$.ajax({
url: '<%: Url.Action("UpdateFlags", null, new RouteValueDictionary(new {Model.ParentId, Model.Page }))%>',
data: Id,
success: function (data) {
alert(data.success);
},
error: function () {
alert("error");
}
});

});

could anyone tell me how can i calculate values using jquery and then send it to the controller. 


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>