我有单选按钮,我在每个单选按钮上存储了一些值
$(document).on('change', '.vEditTamplateId', function ()
{
var vpath = "";
$(".vEditTamplateId").each(function () {
if ($(this).is(":checked") == true) {
vpath = $(this).attr('idd');
$('input[id$=hdnEmpName]').val(vpath);
}
})
});
这是它的代码......
我使用过这个asp.net服务器端控件
<input type="hidden" id="hdnEmpName" runat="server" />
现在使用我背后的代码
string vPath = hdnEmpName.Value;
我总是在这个
中得到空值请建议我适当的建议..
答案 0 :(得分:-2)
function SearchText() {
$(".autosuggest").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "AutoSearchTest.asmx.cs/GetAutoCompleteData",
data: "{'username':'" + document.getElementById('txtSearch').value + "'}",
dataType: "json",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.split('/')[0],
val: item.split('/')[1]
}
}));
},
error: function (xhr, status, error) {
alert("Error: " + xhr.responseText);
}
});
},
select: function (event, ui) {
$('#lblUserId').text(ui.item.val);
}
});
}
[WebMethod]
public List<string> GetAutoCompleteData ( string username )
{
List<string> result = new List<string>();
using ( SqlConnection con = new SqlConnection( System.Configuration.ConfigurationManager.ConnectionStrings[ "ERP_ConnectionString" ].ToString() ) )
{
string query= "SELECT Code, [Description] from tablename Where Compcode = '01' and Description LIKE '%'+@SearchText+'%'";
using ( SqlCommand cmd = new SqlCommand( query, con ) )
{
con.Open();
cmd.Parameters.AddWithValue( "@SearchText", username );
SqlDataReader dr = cmd.ExecuteReader();
while ( dr.Read() )
{
result.Add( string.Format( "{0}/{1}", dr[ "Code" ], dr[ "Description" ] ) );
}
}
}
return result;
}