troubleshooting Question

Populate textbox from database using ajax

Avatar of TonyReba
TonyRebaFlag for United States of America asked on
AJAXASP.NET
16 Comments1 Solution789 ViewsLast Modified:
Hi, I have the following scenario: An SQL 2000 database with a table containing the columns UserID and UserName. A webpage with TextBox1 and TextBox2.

I need to use  AJAX  or Jquey to accomplish the following: When I type the patient ID  in txtPatientId textbox and press the Tab key, txtMRN will populate with the corresponding MRN number.

How do implement this this is what I  have but is not working.


[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    public static string GetDynamicContent(string contextKey)
    {
        string outputString = string.Empty;
        string strConn = ConfigurationManager.ConnectionStrings[""].ConnectionString;
        SqlConnection dbConnection = new SqlConnection(strConn);
        
        SqlCommand dbCommand = new SqlCommand
        ("SELECT TPM300_PAT_VISIT.vst_ext_id AS VisitID,  FROM TABLE ......"

  return outputString;

Open in new window

<asp:TextBox ID="txtMRN" runat="server" MaxLength="15"></asp:TextBox>
            <asp:DynamicPopulateExtender ID="txtMRN_DynamicPopulateExtender" runat="server" 
                Enabled="True" PopulateTriggerControlID="btn_Go" ServiceMethod="GetDynamicContent" 
                TargetControlID="txtMRN" ContextKey="txtPatientId">
            </asp:DynamicPopulateExtender>

Open in new window

ASKER CERTIFIED SOLUTION
leakim971
Multitechnician
Join our community to see this answer!
Unlock 1 Answer and 16 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros