admin管理员组文章数量:1026103
I have the following scenario: An SQL 2000 database with a table containing the columns UserID and UserName. A webpage with TextBox1 and TextBox2.
I need to use JQuery, plain JavaScript or AJAX to acplish the following: When I type the UserID in TextBox1 and press the Tab key, TextBox2 will populate with the corresponding UserName.
I have this implementation in ASP.NET using C# and calling a web service, however I want to avoid postbacks when doing the table search and I know JavaScript or AJAX is the way to go.
Thank you.
I have the following scenario: An SQL 2000 database with a table containing the columns UserID and UserName. A webpage with TextBox1 and TextBox2.
I need to use JQuery, plain JavaScript or AJAX to acplish the following: When I type the UserID in TextBox1 and press the Tab key, TextBox2 will populate with the corresponding UserName.
I have this implementation in ASP.NET using C# and calling a web service, however I want to avoid postbacks when doing the table search and I know JavaScript or AJAX is the way to go.
Thank you.
Share Improve this question edited Nov 27, 2009 at 4:23 Zinoo asked Nov 27, 2009 at 4:17 ZinooZinoo 1852 gold badges3 silver badges7 bronze badges2 Answers
Reset to default 4There are a few different ways to do this. The easiest is to use an UpdatePanel. This will basically be a drop in solution which will work with your existing code.
If you want to use jQuery, you will need to add a webservice or something else to return the data. You can call the webservice with jQuery like this
var parameters = { UserId: userId }
$.ajax({
type: "POST",
url: "http://url to webservice",
data: parameters,
contentType: "application/json;
charset=utf-8",
dataType: "json",
success: function(result) {
$("#id of username field").val(result);
},
error: function(e) {
alert(e);
}
});
Use AJAX.
jQuery has some built in ajax functionality.
You can issue an AJAX request to the server and get the result and fill the result to the textbox.
I have the following scenario: An SQL 2000 database with a table containing the columns UserID and UserName. A webpage with TextBox1 and TextBox2.
I need to use JQuery, plain JavaScript or AJAX to acplish the following: When I type the UserID in TextBox1 and press the Tab key, TextBox2 will populate with the corresponding UserName.
I have this implementation in ASP.NET using C# and calling a web service, however I want to avoid postbacks when doing the table search and I know JavaScript or AJAX is the way to go.
Thank you.
I have the following scenario: An SQL 2000 database with a table containing the columns UserID and UserName. A webpage with TextBox1 and TextBox2.
I need to use JQuery, plain JavaScript or AJAX to acplish the following: When I type the UserID in TextBox1 and press the Tab key, TextBox2 will populate with the corresponding UserName.
I have this implementation in ASP.NET using C# and calling a web service, however I want to avoid postbacks when doing the table search and I know JavaScript or AJAX is the way to go.
Thank you.
Share Improve this question edited Nov 27, 2009 at 4:23 Zinoo asked Nov 27, 2009 at 4:17 ZinooZinoo 1852 gold badges3 silver badges7 bronze badges2 Answers
Reset to default 4There are a few different ways to do this. The easiest is to use an UpdatePanel. This will basically be a drop in solution which will work with your existing code.
If you want to use jQuery, you will need to add a webservice or something else to return the data. You can call the webservice with jQuery like this
var parameters = { UserId: userId }
$.ajax({
type: "POST",
url: "http://url to webservice",
data: parameters,
contentType: "application/json;
charset=utf-8",
dataType: "json",
success: function(result) {
$("#id of username field").val(result);
},
error: function(e) {
alert(e);
}
});
Use AJAX.
jQuery has some built in ajax functionality.
You can issue an AJAX request to the server and get the result and fill the result to the textbox.
本文标签: aspnetPopulate TextBox from Database using JQuery or AJAXStack Overflow
版权声明:本文标题:asp.net - Populate TextBox from Database using JQuery or AJAX - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745623496a2159718.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论