Click here to Skip to main content
15,879,095 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,
When I list the database by filtering the data into the textbox values ​​and would like to assign selected value textbox.

Thanks
Posted
Updated 27-Aug-12 4:47am
v2
Comments
Dave Kreskowiak 27-Aug-12 11:00am    
Ummm....what? I can appreciate that English probably isn't your 1st language, but this made no sense at all.

Are you asking how to filter a database list based on what the user is typing??
Yılmaz Korkmaz 27-Aug-12 11:03am    
I want to filter a field in the database table.
Value of the function can not send.

@using (Html.BeginForm())
{
Html.EnableUnobtrusiveJavaScript(true);
@Html.ValidationSummary(true)
<fieldset>
<div class="editor-label">
@Html.LabelFor(model => model.sender_name)
</div>
<div class="editor-field">
@Html.TextBox("sendername", null, new { onkeyup = "GetSenderName(this.value);" })

@Html.Hidden("sender_name")
@Html.ValidationMessageFor(model => model.sender_name)
</div>
<p>
<input type="submit" value="Submit" />
</p>
</fieldset>
}
<script type="text/javascript">
function GetSenderName(value) {
$.ajax({
type: "GET",
url: "/RCV/GetSenderName",
data: "{id:" + value + "}",
contentType: "application/json; charset=utf-8",
success: function (msg) {
$("#senderContent").html(msg.toString);
},
error: function () {
alert("not connected!");
}
});
}
</script>
Christian Graus 27-Aug-12 11:38am    
Don't use unobtrusive javascript, it's very limited. Use straight jQuery.

1 solution

You also don't want to make AJAX calls on every keypress. You could use a timer to make it fire when the keys stop being pressed, or use the blur event to do it when focus is lost. Assigning a value to a textbox is trivial is jquery - $("#txtboxid").val(myVal); If that's not what you want, your question is too unclear to know what you need.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900