Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Javascript Ajax database MVC3 , +
Hi,
When I list the database by filtering the data into the textbox values ​​and would like to assign selected value textbox.
 
Thanks
Posted 27-Aug-12 5:42am
Edited 27-Aug-12 5:47am
v2
Comments
Dave Kreskowiak at 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 at 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 at 27-Aug-12 11:38am
   
Don't use unobtrusive javascript, it's very limited. Use straight jQuery.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
0 Afzaal Ahmad Zeeshan 256
1 OriginalGriff 251
2 BillWoodruff 240
3 Maciej Los 230
4 Sergey Alexandrovich Kryukov 195
0 OriginalGriff 6,419
1 Sergey Alexandrovich Kryukov 6,008
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,070


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 27 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100