小编mee*_*na 的帖子

根据数据库中的另一个文本框填充文本框值

我正在尝试根据另一个文本框填充文本框值,但我无法填充其他文本框.我正在分享我的代码,请指导我最好的解决方案

行动方法:

public JsonResult AgreementNo(string id)
{
    string no;
    string _str = id;
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString());
    SqlCommand cmd = new SqlCommand("SELECT top(1) num from loan where id=@str", con);
    cmd.Parameters.AddWithValue("@str",id);
    cmd.CommandType = CommandType.Text;
    DataSet ds = new DataSet();
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    da.Fill(ds);
    no = ds.Tables[0].Rows[0]["num"].ToString();
    return Json(new
        {
         no = no
        }, JsonRequestBehavior.AllowGet);
    }
Run Code Online (Sandbox Code Playgroud)

脚本:

 $("#BarrowerName").blur(function () {                    
 $.ajax({                      
 url: '@Url.Action("AgreementNo", "Home")',
 // url: '@Url.Action("AgreementNo", "Home")',
 dataType: "json",
 data: JSON.stringify({ id: $("#BarrowerName").val() }),
 type:"POST",
 async: false,
 contentType: …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc jquery

5
推荐指数
1
解决办法
1185
查看次数

标签 统计

asp.net ×1

asp.net-mvc ×1

c# ×1

jquery ×1