0

Like the title, I used jquery autocomplete to set some text to some of my labels. Then, click save, but the event save in code behind only recieve "" from the labels.Text even though they already have text. Here is my code.

    <input id="search" type="text" placeholder="search" />
    ...
    <asp:Label ID="LabelNYCNhanVienName" runat="server"></asp:Label>
    ...
    <script type="text/javascript">
        $(document).ready(function () {


       $("#search").autocomplete({
            showHeader: true,
            select: function (event, ui) {
                this.value = (ui.item ? ui.item.FullName : ' ');
                $('#<%= LabelNYCNhanVienName.ClientID %>').text(ui.item ? ui.item.bab: ' ');
                return false;
            },
            minLength: 2,
            source: function (request, response) {
                $.ajax({
                    ...
                });
            }
        });
});

code Behind:

void ButtonSave_Click(object sender, EventArgs e)
        {
            Titi item = new Titi ();

            item.titiName = LabelNYCNhanVienName.Text; 
            //My problem is here: the LabelNYCNhanVienName.Text always
            //return "" even when i use firebug at that time to catch the LabelNYCNhanVienName  
            //It still have text in it.

            OnSave_Event(item);
        }

Here is the picture when i debug. At the save event, the Label still has Text:

enter image description here

Hope you can help me get text from the labels. Thank you

Frzzy
  • 299
  • 1
  • 2
  • 16
  • 1
    Following link http://stackoverflow.com/questions/10128530/set-text-property-of-asplabel-in-javascript-proper-way might be helpful for you – Gopi Bandla Feb 12 '15 at 05:45
  • Thank you so much. It's really help. Sorry i cannot find that question. – Frzzy Feb 12 '15 at 07:09
  • Gop Bandla give me this answer. It work for me. Thank so much. http://stackoverflow.com/questions/10128530/set-text-property-of-asplabel-in-javascript-proper-way – Frzzy Feb 12 '15 at 07:27

0 Answers0