Currently, I am utilizing Ajax Autocomplete to search for student names and retrieve their corresponding student ID. The layout of my update panel is as follows:
<asp:UpdatePanel ID="StudentSearchUpdatePanel" runat="server">
<ContentTemplate>
<dl>
<dt>Please input student ID:</dt>
<dd>
<asp:TextBox ID="StudentIDTextBox" runat="server" Wrap="False" MaxLength="6"></asp:TextBox>
<asp:Button ID="SelectStudentIDButton" runat="server" Text="Select" OnClick="SelectStudentIDButton_Click" />
<asp:Label ID="StudentIDEntryError" runat="server" Visible="false" Font-Bold="True" ForeColor="Red" Text="Please enter a 6-digit student ID number."></asp:Label>
</dd>
<dt>Alternatively, start typing the student's last name:</dt>
<dd><asp:TextBox ID="StudentNameSearchTextBox" runat="server"></asp:TextBox></dd>
</dl>
<ajaxToolkit:AutoCompleteExtender ID="StudentNameSearchTextBox_AutoCompleteExtender" runat="server"
TargetControlID="StudentNameSearchTextBox"
ServiceMethod="GetStudents"
OnClientPopulated="getStudents_Populated_Json"
OnClientItemSelected="selected_Student"
MinimumPrefixLength="2"
CompletionSetCount="20"
UseContextKey="True" >
</ajaxToolkit:AutoCompleteExtender>
</ContentTemplate>
</asp:UpdatePanel>
The function getStudents_Populated_Json has the following structure:
function getStudents_Populated_Json(sender, e) {
var students = sender.get_completionList().childNodes;
for (var i = 0; i < students.length; i++) {
var student = eval('(' + students[i]._value + ')');
students[i].innerHTML = student.LastName + ' ' + student.FirstName;
}
Lastly, in the selected_student function:
function selected_Student(sender, e) {
var selectedStudent = eval("(" + e._value + ")");
}
Within selected_student, I aim to locate the ID of the UpdatePanel (StudentSearchUpdatePanel) so that I can subsequently identify "StudentIDTextBox" and insert selectedStudent.ID into StudentIDTextBox.innerHTML. How can I specifically target the StudentIDTextBox and populate its innerHTML from selected_Student?
(Note: The student class includes properties such as ID, FirstName, LastName. It has been confirmed that selectedStudent.ID retrieves the correct identification).
Your assistance is greatly appreciated.