C# 将文本框的ID传递给JQuery

C# 将文本框的ID传递给JQuery,c#,jquery,autocomplete,C#,Jquery,Autocomplete,我有一个带有JQuery自动完成功能的三个文本框的页面,我在JQuery中硬编码了文本框的ID,以便像这样自动完成 $(function () { $('["#txtDocType"],["#txtOtherType"],["#txtFormType"]').autocomplete({ source: function (request, response) { $.ajax({ type: "POST", contentType: "ap

我有一个带有JQuery自动完成功能的三个文本框的页面,我在JQuery中硬编码了文本框的ID,以便像这样自动完成

$(function () {
 $('["#txtDocType"],["#txtOtherType"],["#txtFormType"]').autocomplete({
     source: function (request, response) {
     $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "MyPage.aspx/MyWebMethod",
        data: "{'prefixText':'" + request.term.toLowerCase() + "', 
        'ddvId':'" + $(this).prop('id') + "'}",
        dataType: "json",
        success: function (data) {
                 response(data.d);
                },
        error: function (result) {}
                 });
            },
            minLength: 1
        }); 
  });

在某些事件中,是否有可能在不硬编码文本框ID的情况下将文本框ID传递给jquery(我在谷歌上搜索了它,看到了这么多页面,但没有任何帮助)

从此更新html:

<input type="text" id="txtDocType" />
<input type="text" id="txtOtherType" />
<input type="text" id="txtFormType" />

您甚至可以为三个文本框指定一个类,并且可以在Jquery函数中使用这个类,而不是三个文本框id's@AnoopJoshi它是否像
$(“.CommonclassName”).autocomplete({…})我在AnoopJoshi和@harish拥有的所有三个文本框中都使用了公共类名mentioned@Jai通过使用公共类名访问它,它工作了。数据不应该是
数据:{'prefixText':request.term.toLowerCase(),'ddvId':this.id},
<input type="text" id="txtDocType" class="my-text-box" />
<input type="text" id="txtOtherType" class="my-text-box" />
<input type="text" id="txtFormType" class="my-text-box" />
$(function () {
 $('.my-text-box').autocomplete({
     source: function (request, response) {
     $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "MyPage.aspx/MyWebMethod",
        data: "{'prefixText':'" + request.term.toLowerCase() + "', 
        'ddvId':'" + $(this).prop('id') + "'}",
        dataType: "json",
        success: function (data) {
                 response(data.d);
                },
        error: function (result) {}
                 });
            },
            minLength: 1
        }); 
  });