AJAX asp.net error when checking username exists

Hi Experts,

While validating user name exists in the database or not I get the following error messgae. pls help, Happy thanks givig experts

 <asp:UpdatePanel runat="server" ID="UpdatePanel1">
  <ContentTemplate>
        User Name &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; <asp:TextBox runat="server" id="Text5"  AutoPostBack="true"  OnTextChanged="Username_Changed" /> * Minimum 6 charcters
        &nbsp;  &nbsp;<div runat="server" id="UserAvailability"></div>
      &nbsp;&nbsp;</ContentTemplate>
</asp:UpdatePanel>

 Protected Sub Username_Changed(ByVal sender As Object, ByVal e As EventArgs)
        Response.Write("Got it")
       

        Dim uname As New username
        If uname.isuserexist(Text5.Text) = False Then
            UserAvailability.InnerText = "Username taken, sorry."
            UserAvailability.Attributes.Add("class", "taken")
        Else
            UserAvailability.InnerText = "Username available!"
            UserAvailability.Attributes.Add("class", "available")
        End If
    End Sub

    Private Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        'There should be some checking done so that not all the errors
        'are cleared
        Context.ClearError()
    End Sub


Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.6; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; InfoPath.2; BRI/1; .NET4.0C; .NET4.0E)
Timestamp: Wed, 24 Nov 2010 02:03:57 UTC


Message: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
Line: 938
Char: 13
Code: 0
URI: http://localhost:50439/WebSites/ScriptResource.axd?d=p9YF5iPLsQD8mOYNrJmFZ0X4J_f0F9TTQNLVdebTb5kap23rnUdRycjeOBu9Mot6znLManF9uxkXdEWUAFJBXQ2&t=11e6618b

STEVE00098Asked:
Who is Participating?
 
Greg GambleConnect With a Mentor ProgrammerCommented:
Only other thing I can think of is to add the TextBox "Text5" as a trigger in the update panel. for the OnTextChanged event
0
 
Kumaraswamy RCommented:
After including a control from the ASP.Net AjaxControlToolkit version 3.5 -  we got this error:
Microsoft JScript runtime error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the ToolkitScriptManager in AjaxControlToolkit.dll.
3.1.1.      Solution
I believe there are many other problems which can cause this symptom, but in my case, as the error message says, the solution is that you need to include the “ToolkitScriptManager” rather than the standard “ScriptManager”
To add the ToolkitScriptManager, you first need to include the assembly namespace on your aspx page.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
TagPrefix=" AjaxToolkit" %>
Or in the “web.config”
<system.web>
            <httpRuntime maxRequestLength="10240"/>
            <pages>
                  <tagMapping>
                        
                  </tagMapping>
                  <controls>
                        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                      <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"  />
                        <add tagPrefix="cc1" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit.HTMLEditor"  />
                  </controls>
            </pages>
If you control is right on your main page, chances are you have already done this.  But in my case the Ajax control was embedded in a user control, so I didn’t have it on the main page yet.
Then you can simply include the manager by changing the standard script manager
<asp:ScriptManager ID="scriptMaster" runat="server"></asp:ScriptManager>
To this:
<asp:ToolkitScriptManager ID="toolkitScriptMaster" runat="server">
</asp:ToolkitScriptManager>

3.2.      Microsoft JScript runtime error:Sys.WebForms.PageRequestManagerServerErrorException
We got this annoying error recently in a website I've been working on.  It worked perfectly fine locally, it worked fine after uploading to the web server on my machine and other machines in the lab (various browsers).  Then, it turns out, it doesn't work on (one of) the client's machines.  Of course, I'm unable to replicate the error locally.
I looked around and it seems the first solution was to clear the cache.  A lot of people said that Ctrl+F5 works, others said they needed to manually clear the cache and then restart the browser.  Well, neither of those worked.
3.2.1.      Solution
Fortunatelly, the solution turned out to be pretty easy:  Set the "CombineScripts" property of the ToolkitScriptManager to false.
 <ajaxToolkit:ToolkitScriptManager runat="server" ID="ajaxScriptManager" EnablePartialRendering="true" CombineScripts="false" />
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
STEVE00098Author Commented:
Tried both option but no luck
0
 
STEVE00098Author Commented:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="user.aspx.vb" Inherits="user"    validateRequest="false" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>

</head>
<body onload="document.forms.form1.Text1.focus();javascript:winwidth()" style="background-color:#cfd9e3">

<table id="logo"  width="" style="background: #f7edd5; overflow: hidden;" border="2" >
 <tr style="background: #f7edd5" align="center">
    <td  align="left" style="background-color: #f7edd5;color: #0514f2; font-size: 40px; width: 536px;"><asp:Image ID="Image1" runat="server" ImageUrl="" />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <a id="idA_PWD_ForgotPassword1Pwd" style="text-decoration: none; color: #0514f2; font-size: 15pt;" href="http://localhost:50439/WEBSITES/Default.aspx">Home</a>
    </td>
    </tr>
</table>

 <form id="form1" runat="server" method="post" action="Home1.aspx">

   
<script type="text/javascript" language="javascript">


function winwidth(){
var theTable = document.getElementById('logo');
theTable.style.width = (screen.width - 10) + 'px';
}


function resetForm(){
document.getElementById("Submit1").disabled = true;
document.getElementById("Reset1").disabled = true;

var frmMain = document.forms[0];
frmMain.reset();
document.forms.form1.Text1.focus()
}



</script>
   
  <table>
  <tr>
      <cc1:ToolkitScriptManager ID="ToolkitScriptManager1" EnablePartialRendering="true" runat="server" CombineScripts="false">
      </cc1:ToolkitScriptManager>
  <td style="color: red; width: 627px;">
    <label> First Name &nbsp;&nbsp;&nbsp;&nbsp;
    </label>
        &nbsp;<input id="Text1" type="text" name="Text1" maxlength="10" /> * Minimum 3 charcters
        &nbsp; <br />
        <label> Last Name</label>
        &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<input id="Text2" type="text"  maxlength="10" name = "Text2" style="width: 155px" /> * Minimum 2 charcters
        &nbsp; <br />
        <label> Email Adress&nbsp; &nbsp;</label><input name="Text3" maxlength="40" id="Text3" type="text" style="width: 155px" />
        &nbsp; <br /> <asp:UpdatePanel runat="server" ID="UpdatePanel1">
  <ContentTemplate>
        User Name &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; <asp:TextBox runat="server" id="Text5"  AutoPostBack="true"  OnTextChanged="Username_Changed" /> * Minimum 6 charcters
        &nbsp;  &nbsp;<div runat="server" id="UserAvailability"></div>
      &nbsp;&nbsp;</ContentTemplate>
</asp:UpdatePanel>
0
 
Greg GambleProgrammerCommented:
Make sure that the System.Web.Extensions you are using, either in the GAC or in the bin folder, are version 3.5
0
 
STEVE00098Author Commented:
verified the version (screen shot attached) web.extensions
0
 
Greg GambleProgrammerCommented:
Remove the "Response.Write("Got it")".  It looks like your messing with the update panel postback.
0
 
STEVE00098Author Commented:
removed response.write("got it") but still get the error. Does any one have working code to verify username exist or not via AJAX.
0
All Courses

From novice to tech pro — start learning today.