ASP.Net Ajax Error: There was an error processing the request

Last Reply 3 months ago By dharmendr

Posted 3 months ago

hi all

At the beginning of typing in the text box

This message appears and when you click Accept, the message will disappear without any problems on the page

It appears only once

{"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}

 

public partial class daily : System.Web.UI.Page
{
    [System.Web.Script.Services.ScriptMethod()]
    [System.Web.Services.WebMethod]
    public static List<string> GetCompletionList(string prefixText)
    {
        using (OracleConnection con = new OracleConnection("data source=localhost:1521/orcl; user id=alhakimy; password=alhakimyyes;"))
        {
            using (OracleCommand com = new OracleCommand())
            {
                com.CommandText = "select doc_no, doc_name from doctors where city_no= " + HttpContext.Current.Session["city_no"].ToString() + " and doc_name like '%" + prefixText + "%' ";
                com.Parameters.Add("TextBox1", prefixText);
                com.Connection = con;
                con.Open();
                List<string> summ = new List<string>();
                using (OracleDataReader sdr = com.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        summ.Add(string.Format("{0}-{1}", sdr["DOC_NAME"], sdr["Doc_NO"]));//اذا اضفنا عمود جملة السكلته سنضيفه هنا كالبقية
                    }
                }
                con.Close();
                return summ;
            }
        }
    }
    
    protected void Submit(object sender, EventArgs e)
    {
        string doc_name = Request.Form[TextBox1.UniqueID];
        string doc_no = Request.Form[hfdoc_no.UniqueID];
        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Name: " + doc_name + "\\nNO: " + doc_no + "');", true);
    }   
}

 

<%@ Page Language="C#"  MaintainScrollPositionOnPostback="true" AutoEventWireup="true" CodeFile="daily.aspx.cs" Inherits="daily" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta charset="utf-8" />   <!-- قبول الرموز في المتصفح -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />   <!-- توافق العمل مع اكسبلورر -->
    <meta name="viewport" content="width=device-width, initial-scale=1" />   <!-- التوافق مع الموبايل -->
    <title>Daily Report</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/jquery-ui.min.js"></script>
    <link rel="Stylesheet" type="text/css" href="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/themes/blitzer/jquery-ui.css" />
    <script type="text/javascript">
    $(function () {
        $("[id$=TextBox1]").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: '<%=ResolveUrl("~/daily.aspx/GetCompletionList") %>',
                    data: "{ 'prefixText': '" + request.term + "'}",
                    dataType: "json",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    success: function (data) {
                        response($.map(data.d, function (item) {
                            return {
                                label: item.split('-')[0],
                                val: item.split('-')[1]
                            }
                        }))
                    },
                    error: function (response) {
                        alert(response.responseText);
                    },
                    failure: function (response) {
                        alert(response.responseText);
                    }
                });
            },
            select: function (e, i) {
                $("[id$=hfdoc_no]").val(i.item.val);
            },
            ///////////هذا القسم يقو باضهار رساله في حاله قام المستخدم بكتابة اسم من خارج القائمة
            change:function(e, ui){
                if(!(ui.item)){
                    e.target.value="";
                    alert("الاختيار من القائمة فقط");
                }
            },
            ///////////
            minLength: 1
        });
    });  
</script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server" onpaste="return false" oncopy="return false" oncut="return false" Height="30px" style="font-size: large; font-weight: 700" Width="235px"  Enabled="False" autocomplete="off"></asp:TextBox>
    </form>
</body>
</html>

 

This question does not have replies that have been liked.