在asp.net MVC中,如何使用AutoPostBacking在部分视图中更改TextBox的值

我对MVC Asp.net中的Auto Postbacking很新。 我需要更改textbox2的值 ,而自动回发部分视图自动 回复应该只在文本框1中单击后发生

问题:textbox2在自动后备后没有更改值。

进一步的发现:Post Success Function正在运行(“函数SetData(data)”),所以当我调试代码时,AutoPostBacked到ActionMethod:“Test()”并执行代码并返回到_PartialViewTwo并执行代码dere,但它没有更改TextBox2值

注意:TextBox1位于PartialViewOne中,TextBox2位于PartialViewTwo中

在此先感谢您的帮助。

// 回家

public ActionResult Index() { Response.Write("working Index"); Student Model = new Student(); Model.RollNo = 1; Model.Name = "Arun"; return View(Model); } [HttpPost] public PartialViewResult Test() { Student Model = new Student(); Response.Write("working test3"); Model.Name = "Afsal"; return PartialView("_PartialViewTwo",Model) ; } 

家庭观点

 @model test1.Models.Student @using (Html.BeginForm("Index","Home",FormMethod.Post)) { 
@Html.LabelFor(x=>x.RollNo) @Html.Partial("_PartialViewOne",Model)
@Html.Partial("_PartialViewTwo",Model)
}

PartialViewOne

  @Html.TextBox("txt1")   $(document).ready(fun1) function fun1() { alert("ready"); $("#txt1").click(fun2); } function fun2() { alert("click"); $.ajax({ url: '@Url.Action("Test/Home")', data: null, cache: false, type: "POST", dataType: "html", success: function (data, textStatus, XMLHttpRequest) { SetData(data); } }); } function SetData(data) { alert("again"); $("#divPartialView").html(data); // HTML DOM replace }  

PartialViewtwo

 @model test1.Models.Student @Model.Name 

@To all:问题已解决。 它在选择器“ $(”#divPartialView“). html(数据)”里面的jquery函数“函数SetData(data) ”中出现区分大小写的错误,现在它改为“ $(”#divpartialview“) ”.. …… ….:P

 function SetData(data) { alert("again"); $("#divpartialview ").html(data); // HTML DOM replace }