Updating Text Box Using Ajax [Resolved]

Posted by Self-Innovator under ASP.NET AJAX on 4/22/2016 | Points: 10 | Views : 211 | Status : [Member] | Replies : 1
Hi All,

I am new to AJAX and i wanted to update the text box field value with an Ajax call in my partial view

My code is below
My Partial View
<div class="input-group">
<input id="busEmail" type="text" class="form-control" aria-label="..." value="@Html.DisplayFor(x => x.StoreProfileAssociation.BusinessEmail)" />
<div class="input-group-btn">
<button id="ComPrefrence" class="btn btn-default" type="button">GO</button>
<script src="~/Scripts/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
$('#ComPrefrence').click(function () {
var commPref;
var busEmail = $("#busEmail").val();
commPref = "UpdateMemberPreference";
type: 'POST',
data: { 'StoreId': '00316','CEM':'CEM','busEmail':'busEmail' },
datatype: "json",
url: commPref,
success: function (data) {
window.location = 'Index.cshtml';
error: function (result) {
alert('Failed to load the result');

public ActionResult UpdateMemberPreference(int StoreId)
StoreId = 00316;
string busEmail="mike.weeder1@truevalue.com";
XmlDocument xmlDoc = new XmlDocument();

string CommunicationPreferenceXml = _reportService.UpdateMemberPreference(StoreId, "CEM", busEmail);

var communicationPrefViewModel = new StoreInfoViewModel();

//check for a an "error" node within the results
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("ns", "http://wsdev.truserv.com/oraclewebservice/oraclemdb.asmx");
XmlNode Node = xmlDoc.SelectSingleNode("*/memberpreferences/memberpreference[@preference_item_code='CEM']", nsmgr);

XmlNode Nodes = Node.SelectSingleNode("*/memberpreferences/memberpreference[@preference_category='Broadcast Message To E-Mail Preferences']", nsmgr);

return PartialView("_communication", communicationPrefViewModel);
catch (Exception ex)
throw ex;

My WebService Call

public string UpdateMemberPreference(int StoreId,string CEM,string busEmail)
dynamic communicationPrefWebService = string.Empty;

//if UAT passport service flag is enabled, then connect to UAT passport else connect to production passport
if (settings.IsUATBusinessReportService)
communicationPrefWebService = new UATStoreReportServiceReference.oraclemdb1SoapClient("oraclemdb1Soap");
return communicationPrefWebService.UpdateMemberInfo(StoreId.ToString(),"CEM",busEmail);

I have a text box in my partial view which is already binded with old email id ex:-ahmed.k@gmail.com, Now i want to update "ahmed.k1@gmail.com" and result should be updated by calling the service but finally i want

Join Hands Change lives
Thanks & Regards
Straight Edge Society


Posted by: Maryafleming on: 4/28/2016 [Member] Starter | Points: 50


Your textbox value can't be updated untill you put it in an update panel.
<asp:TextBox ID="TextBox5" runat="server" />
<asp:Button ID="btn" runat="server" onclick="btn_Click" />
Reference: http://american-writers.org/

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response