Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

AJAX asp.net error  when checking username exists

Posted on 2010-11-23
9
Medium Priority
?
716 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:STEVE00098
9 Comments
 
LVL 21

Expert Comment

by:Alfred A.
ID: 34202276
0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 34204216
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
 

Author Comment

by:STEVE00098
ID: 34210145
Tried both option but no luck
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:STEVE00098
ID: 34210149
<%@ 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
 
LVL 5

Expert Comment

by:Greg Gamble
ID: 34210256
Make sure that the System.Web.Extensions you are using, either in the GAC or in the bin folder, are version 3.5
0
 

Author Comment

by:STEVE00098
ID: 34210364
verified the version (screen shot attached) web.extensions
0
 
LVL 5

Expert Comment

by:Greg Gamble
ID: 34210653
Remove the "Response.Write("Got it")".  It looks like your messing with the update panel postback.
0
 

Author Comment

by:STEVE00098
ID: 34212722
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
 
LVL 5

Accepted Solution

by:
Greg Gamble earned 2000 total points
ID: 34212994
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question