Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Wednesday, March 28, 2012

Why My AutocompleteExtender doesnt work Im gone crazy!!

Hi All!!!

I'm looking for help. I read lot of post in this forum but my AutocompleteExtender still not work. Can somebody help please!

this is my code behind of my Webservice

1using System;2using System.Data.SqlClient;3using System.Web;4using System.Collections;5using System.Collections.Generic;6using System.Web.Services;7using System.Web.Services.Protocols;8910/// <summary>11///12/// </summary>13[System.Web.Script.Services.ScriptService]14[WebService(Namespace ="http://tempuri.org")]15[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1, EmitConformanceClaims = true)]16public class AutocompleteList : System.Web.Services.WebService {1718 public AutocompleteList () {1920//Uncomment the following line if using designed components21 //InitializeComponent();22 }2324 [WebMethod]25 [System.Web.Script.Services.ScriptMethod]26 public string[] GetList(string prefixe, int count)27 {28 List<string> art = new List<string>();29 string cnx = global::System.Configuration.ConfigurationManager.ConnectionStrings["artistesSQLServices"].ConnectionString;30 string select = "SELECT DISTINCT nom FROM [Table] WHERE nom LIKE @dotnet.itags.org.VALUE";31 SQLServer server = new SQLServer(cnx);32 if (server.Connect.State == System.Data.ConnectionState.Open)33 {34 SqlDataReader reader = null;35 SqlCommand cmd = new SqlCommand(select, server.Connect);36 cmd.Parameters.Add(new SqlParameter("@dotnet.itags.org.VALUE","%" + prefixe + "%"));37try38 {39 reader = cmd.ExecuteReader();40 cmd.Parameters.Clear();41 }42catch (Exception ex)43 {44string mess = ex.Message;45 }46finally47 {48if (reader.HasRows)49 {50while (reader.Read())51 {52 art.Add(reader.GetValue(0).ToString());53 }54 }55 reader.Close();56 reader.Dispose();57 cmd.Dispose();58 server.SQLDisconnect();59 }60 }61return art.ToArray();62 }63}

this is the code of my aspx page

<%

@dotnet.itags.org.PageLanguage="C#"MasterPageFile="~/users/Site.master"AutoEventWireup="true"

CodeFile

="Test.aspx.cs"Inherits="users_Test"Title="Untitled Page" %>

<%

@dotnet.itags.org.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"Namespace="System.Web.UI"TagPrefix="asp" %>

<%

@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

<

asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><asp:ScriptManagerID="ScriptManager1"runat="server"EnablePageMethods="true"EnablePartialRendering="true"></asp:ScriptManager><ajaxToolkit:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server"TargetControlID="TextBox2"ServiceMethod="GetList"ServicePath="../AutocompleteList"CompletionInterval="10"CompletionSetCount="10"MinimumPrefixLength="3"Enabled="true"EnableCaching="true"></ajaxToolkit:AutoCompleteExtender> <asp:TextBoxID="TextBox2"runat="server"></asp:TextBox>

</

asp:Content>

Hi,

Change your First Parameter "string prefixe" to be "string prefixText" . The Parameters are hard-coded in the WebService Invocation.

Check this Thread ..http://forums.asp.net/1598039/ShowThread.aspx#1598039


thanks for your help phanatic it works very well ............ BUT in debug mode only

when i call my page by this url :http://mymachine/mypage.aspx the autocompletion doesn't work. Do you know why?


ok,

we are making progressSmile

I see that you are calling an ASPX Page , are you trying to use the PageMethods ?

If you are , Please checkhttp://forums.asp.net/thread/1205564.aspx

If it resolves your issue , please mark my reply as the answer


still doesn't work!

I have "myage.aspx" which contains the autocompleteextender, and 2 others files (Autocomplete.asmx and Autocomplet.cs) which contains the code of my webservice


still doesn't work!

I have "myage.aspx" which contains the autocompleteextender and the two files of my webservice the "Autocomplet.asmx" and the code-behind "Autocomplete.cs"


hi,

Please drop me a sample at Phani_Rajyn@.yahoo.co.in


i've just sent you a sample

Hi ,

The sample contains SQLDataSource Connections and a lot of dependencies .

I cannot run this on my machine

can you please send me a self-contained sample that can run anywhere ?


hi phana

i've done some test with an other code in my webservice like this

1[WebMethod]2 [System.Web.Script.Services.ScriptMethod]3public string[] GetCompletionList(string prefixText,int count)4 {5int i = 0;6int iLength = 10;7 List Values =new List<string>();8for (i = 0; (i < iLength); i++)9 {10 Values.Add(Convert.ToString(prefixText + i.ToString()));11 }12 String[] strReturn =new String[Values.Count];13 strReturn = Values.ToArray();14return (strReturn);15 }

this code work very fine in debug mode and in normal mode. In my code i'm connecting to a SQLSERVER 2005 in an other machine.


I've done a test

I code a new page aspx just with the textbox an the autocompleteextender

i try my webservice it works fine. but when i add my website in IIS the autocompletextender doesn't work. it seems to be an issue in my IIS settings con you tell me what are the settings for IIS please


Hi,

"this code work very fine in debug mode and in normal "

If the code above works , then there are no issues with the AutoCompleteExtender , you should investigate the calls to the SQL Server you are making to understand what the issue is .

As far as IIS is concerned, are you gettting any errors related to IIS configuration ?


i find the issue it seems that IIS don't use my authentification to connect to the sqlserver

i've change my connection string and use the "sa" id user and password to connect

thx a lot for your help phana


just an other question can tell me how can i do a drag n drop from a textbox to an other textbox?

Hi,

great to know that we resolved the issue.

Can you please mark my reply as the answer ?

Why my web services cant accept parameter?

When my javascript call the echoString(s) in the following code, it return nothing

<%@dotnet.itags.org. WebService Language="C#" Class="WebService" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService {

[WebMethod]
public string echoString(string s) {
return s;
}

}

The strange things are my .NET program works fine with the code above and my javascript client program doesn't work with the code above but works fine with other people's web services. EX:

http://www.mssoapinterop.org/asmx/simple.asmx?op=echoString

What is wrong with my code? Thank you!!!!!!!!!

asdpai:

what is wrong with my code?

nothing, code is correct. Decorate youre WebService with theSystem.Web.Script.Services.ScriptService() and the WebMethode with the ScriptMethod() attribute eg.

<%@. WebService Language="C#" Class="WebService" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
usingSystem.Web.Script.Services;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService()]
public class WebService : System.Web.Services.WebService {

[ScriptMethode()]
[WebMethod]
public string echoString(string s) {
return s;
}

}

Hope that coul help.

Why Response.Redirect() opens up a new browser window in AJAX?

I have an AJAX enabled page displayed in amodal dialog, When I click on a button that has a Response.Redirect() code, a new browser window gets opened, which is weird and not the behavior that I expect.

I should note that this page worked properly before adding the AJAX related stuff.

I highly appreciate any insight into this problem.

try use server.transfer


I had already tried the Server.Transfer but I got a client side alert: "Sys.WebForms.PageRequestManagerParserErrorException: The message recieved from the server could not be parsed,..."
Try to navigate to next page in Javascript instead of on Server side. I think this can solve the issue.

hello.

i think the problem is that submitting a page on a popup will open another window by default. you can workaround this by adding an iframe to your popup window which loads the page you need.


Thanks, I think the only workaround to my problem was to use the IFrame in the modal window, but still, I'm wondering why the use of Server.Transfer() caused the error in AJAX, and, why the Response.Redirect() would open up a new window, was I missing somthing or it's just the way AJAX works!

May I ask that Response.Redirect is logical/possible at all during a partial postback (for example in an updatepanel's button click event)?!

Simply move that specific button which yield Response.Redirect outside of the updatepanel, maybe it helps.


Yes, the button which yielded the Response.Redirect() or Server.Transfer() for that matter, was inside the UpdatePanel, I moved it outside the UpdatePanel and my problem was solved. Actually the UpdatePanel was inside a Container UserControl, I think I should make use of UpdatePanel more narrowly focused.

Thank you very much indeed.


response.redirect will be correctly interpreted by the ajax platform. you can check this by using ?a "normal" page. the problem that was happening here was related with modal dialogs and the issue described is not an ajax problem.

server.transfer won't work correctly with ajax and shouldn't be used from controls placed inside the updatepanel. this is understandable because partial postbacks expect to receive a predefined message from the server and whe you do a server.transfer you end up retunring a new page to the user which doesn't conform to the expected message.

So response.redirect works with ajax.

If ajax open the redirected page via javascript (maybe using window.open( ... ) ), that can be a problem.

Modern tabbed browsers are configurable how to treat popup pages from normal links or from javascript (new window, same window, new tab, disable totally javascript popups etc.)

I recommend for Robert to try the page in firefox, and play with advanced firefox settings (type about:config in the address bar, and play with "browser.link.open_newwindow.restriction" and similar settings, you can google for help how it works)

ps:

If the button must be in the updatepanel, maybe it is possible to register a script in the server side which open the new window by javascript (a more controlled way.)


I am also running into this problem and am unable to place the control outside of the Update Panel. I am not clear as to how an IFrame would be implemented. Is it meant that an IFrame should be used in place of the AJAX update panel or in addition to? How would this implementation work specifically?

Thanks for any information in advance.


MaybeScriptManager.RegisterPostBackControl could be used to eliminate this problem in some cases.

So leave your button (which has the codebehind redirect logic) in the updatepanel, but use the RegisterPostBackControl method so it will cause a full normal postback. That way you have a normal redirect, not the ajax client side redirect.


Thanks for the responses.

I did try the following on the control that is being clicked to fire the Redirect:

ScriptManager1.RegisterPostBackControl(this.testButton);

Unfortunately, this still launches a new window during the redirect.

Does anyone have any other ideas as to how i can do this? I would be open to attaching some javascript to the button in order to perform the redirect, however, I have already tried adding the following with no success:

ScriptManager.RegisterClientScriptBlock(this.buttonTest,this.buttonTest.GetType(),"Redirect","window.location = 'http://www.testpage.com'",true);


jriell:

I have already tried adding the following with no success:

ScriptManager.RegisterClientScriptBlock(this.buttonTest,this.buttonTest.GetType(),"Redirect","window.location = 'http://www.testpage.com'",true);

If you choose that way (custom client side redirect), I recommend the following to try:

Put a regular input button, link etc. in the updatepanel, for example:

<input type="button" value="test" onclick="window.location.replace( 'http://www.testpage.com' );" />

If that works, try the script withthe RegisterClientScriptBlock stuff.

why ScriptManager is not recognized by VS?

Hi,

I drag and drop AJAX ScriptManager control to the source view of default.aspx, here is the code (the third and fourth lines are for ScriptManager):

<%@dotnet.itags.org. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Status:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem Selected="True" Value="false">Active</asp:ListItem>
<asp:ListItem Value="true">Complete</asp:ListItem>
</asp:DropDownList>

But I found ScriptManager tag is underlined with curly red line. When I mouse hover on ScriptManager tag, I see a tip

Element ScriptManager is not a known element. This can occour if there is a compilation error in the website.

But I could compile and run the site successfully. The bugging thing is that all the AJAX control, such as UpdatePanel is not recognized by VS too.

any idea?

Thx

Tao

From what I know, this is what is happening...

The cause for this error is, in your web.config look for this tag...and change the tagprefix from default asp to anything else...

<controls>
<add tagPrefix="ajax" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls
and now change the <asp:UpdatePanel> to <ajax:UpdatePanel> . All your errors should be gone.

please Let us know if this fixes...


This does solve the problem. But I don't understand why. Originally, the AJAX control defined in System.Web.Extensions is registered as tagPrefix = asp. So when I use asp:ScriptManager tag, VS should be able to locate the assembly and recognize it, theoritically. Do you know why I have to replace "asp" prefix with something else, such as ajax?

Thx

Tao


Theoretically I too expected the same. We found this fix on some blog(Thanks to him for posting it), I forget the link!. But it solved the dirty red squiggly lines and I made a note of it. May be, experts here can give hind sight of why and the details behind this...

Happy Coding :)

Why Sys.Application does not work?

I just begin to learn ASP.NET AJAX. I have a simple question, please bear with me. I want to test client-side page life cycle. Here is my code. I don't know why pageInit does not get called? But pageUnload works.

Thanks a lot!

<head runat="server">
<title>Untitled Page</title>

<script type="text/javascript">
<!--
Sys.Application.add_init(pageInit);


function pageInit()
{
alert("Enter init page.");
}


function pageUnload()
{
alert("Page unloaded!");
}
//-->
</script>
</head>
<body>
<form id="form1" runat="server">

.....

Try putting your Sys.Application.add_init(pageInit) *after* you've defined your pageInit function.


I think I got a error that Sys is undefined. Did I miss including any namespace?

Thanks again!


The problem is fixed. I need to move <script> section after <asp:ScriptManager ID="ScriptManager1" runat="server" />, so that Sys can get reference.


I expierence the same problem, IE7 throws a javascript error "sys is undefined".

I did like you described and put the <asp:ScriptManager> section before my first <script> tag, but it doesn't help.

Have to put the ScriptManager section into my masterpage aspx file because of the <form> tag, could this be the problem?
In the browser output file of my aspx there are still <script> tags above the ScriptManager.

What can I do on this?


Check out this post for ideas about why you might get "sys is undefined":http://weblogs.asp.net/chrisri/archive/2007/02/02/demystifying-sys-is-undefined.aspx.

I guess it probably is the web configuration issue. Create a new AJAX-based web project, copy its web.config to your project to see if it works.

Why The Toolkit DLL is much bigger than download

I download the Version 1.0.10301.0 Ajax Control Toolkit. Both of With Source code and without .I found a question.The ajax control toolkit dll file which is in the without source code package is 764KB(in "\SampleWebSite\Bin" ),but the dll file I generated from the source code is near 1.3MB. Why?

if you compiled in Debug mode, then your assembly would be larger than if you had compiled in Release mode.


oh~~~~~~~~ Right! Thanks for your help answer!

Why this code does not work when its button is inside the AJAX “UpdatePanel” control ?

protectedvoid DownlFile_Click(object sender,EventArgs e)

{

string web_path ="./ items/part1.pdf";

string path = Server.MapPath(web_path);

FileStream MyFileStream =

newFileStream(path,FileMode.Open);

long FileSize;

FileSize = MyFileStream.Length;

byte[] Buffer =newbyte[(int)FileSize];

MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length);

MyFileStream.Close();

Response.ContentType ="application/pdf";

Response.AddHeader

("content-disposition","attachment; filename=part1.pdf");

Response.BinaryWrite(Buffer);

}

Hi paradise_wolf,

You can't use Response.Write in a AsyncPostback trigger event of an UpdatePanel. You need move the button outside the UpdatePanel or register it as Postback trigger.

Hope this helps,


Hispvlong

I am not sure if "RegisterAsyncPostBackControl" registers the button asPostback triggeras you suggested to do. I am getting this error message:

"Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.

Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Details: Error parsing near '%PDF-1.3%□□3389 0'."

Below is the relevant ASP.NET web form code and the added C# code:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

protectedvoid Page_Load(object sender,EventArgs e)

{

ScriptManager1.RegisterAsyncPostBackControl(DownlFile);

..

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<asp:UpdatePanelID="ITEMS_LIST_EREADER_PANEL" runat="server"

UpdateMode="Conditional">

<ContentTemplate>

..

<asp:ButtonID="EreaderBtn"runat="server"Text="Next"

OnClick="EreaderBtn_Click"/>

..

</ContentTemplate>

</asp:UpdatePanel>

<asp:UpdatePanelID="DOWNLOAD_PANEL"UpdateMode="Conditional"

runat="server">

<ContentTemplate>

..

<tableID="DownloadDialogTb"visible="false"runat="server">

<tr>

<tdalign="center">

<asp:ButtonID="DownlFile"runat="server"Text="Download"

OnClick="DownlFile_Click"/>

</td>

</tr>

</table>

..

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTriggerControlId="EreaderBtn"

EventName="Click"/>

</Triggers>

</asp:UpdatePanel>


Hi paradise_wolf,

You should use RegisterPostBackControl method to register a control as Postback trigger.

Hope this helps,


Thank you very much,spvlong . Big Smile

hi,

I am also getting same problem while generating PDF? i could not solver even after registring as postback trigger control. It gives me the same error.

If you have solved it, plz suggest the solution for the same.

thanks

Varsha


http://forums.asp.net/1662626/ShowThread.aspx#1662626

why Timer always reload updatepanel, is it right?

I tried to use timer to reload updatepanel, code like this

<atlas:TimerControl runat="server" ID="timer" Interval="5000"/>

<atlas:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
my controls...

</ContentTemplate>
</atlas:UpdatePanel>

right, I don't define trigger there. But even with code like that, the updatepanel still reload every 5 seconds, why it works this way?

thanks

I think I have found answer.

hello.

well, as you might have guesses by know, you have to set the mode property of the panel to conditional.

Why to use asp.net ajax

Anthem.net is so simple to use on doesnot even have to write a line of code.

Why should we consider using msft asp.net ajax instead of anthem.net ?

thanks

Because ASP.NET Ajax is part of the .Net framework, so you are assured of support, documentation and continued development (and a huge and growing amount of tutorials etc from users). That can never be said of Anthem.Net. What happens if the creator just gets bored with it one day?


do we have to write lines of javascript code with asp.net ajax version?

Thanks for your help


No you don't have to. You can use its basic functionality without writing one line of code. You can also use all the extenders in the control toolkit without writing any javascript. However, you can also customise the behaviours as much as you want by adding some javascript. Watch some of theAjax videos here

Saturday, March 24, 2012

Work at you the OnResolveId event of the HoverMenu control?

Hi

Work at you the OnResolveId event of the HoverMenu control?

With this code it doesn't work

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>

<div id="Div1" runat="server" style="display:none; background-color:ButtonFace; border:solid 1px #ccc;">
<span id="Span2" runat="server">div_hover</span
</div>
<cc1:HoverMenuExtender ID="HoverMenuExtender1"OnResolveControlID="HoverMenuExtender1_ResolveControlID" PopDelay="2"runat="server" PopupControlID="Div1" TargetControlID="LinkButton1"PopupPosition="Right" /
<br /><br /><br /><br /
<asp:Label ID="Label1" runat="server" ></asp:Label


aspx.vb

Protected Sub HoverMenuExtender1_ResolveControlID(ByVal sender AsObject, ByVal e As AjaxControlToolkit.ResolveControlEventArgs) HandlesHoverMenuExtender1.ResolveControlID
Label1.Text = "Hi"
End Sub


What i am wrong?

up


Hi,

What are you trying to achieve?

The ResolveControlID event is defined in the ExtenderControlBase class, and it's called when the ExtenderControlBase fails to locate a control referenced by a TargetControlID. In this event, user code is given an opportunity to find the control.

Hope this helps.


Yes, it was just this, that i wanted to know

that is when start the resolveControlID and what it 's useful

thanks

Work with 1 control

I like the tab control in the toolkit. I would like to use the source code and remove the other controls and adopt the tab control into our code base.

What are the dependencies for this control?

Thanks...

You should keep the code in the Common, ExtenderBase and ScriptResources folders along with everything in theTab folder in the AjaxControlToolkit project and give it a shot. You can always add code incrementally if you discover more dependencies (exclude the rest and see if the tabs demo works).
What's wrong with referencing the entire toolkit and just using the tab control?
I would agree. That is a better approach and would help avoid treading down unsupported paths. The ship dll is very small in size around 750KB.

working from code behind with responsexml

I am working in the generic handler file

Can anybody help me working with responsexml

Hi,

responseXML is what you use to manipulate the response from the server on the client. It's not available on server side directly.

But you have full control on what will be returned to the client side in the ProcessRequest method. For example, the following handler returns a string "Hello World" which is the content of responseXML.

<%@. WebHandler Language="C#" Class="Handler" %
using System;
using System.Web;

public class Handler : IHttpHandler {

public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}

public bool IsReusable {
get {
return false;
}
}

}

working with AJAX?

Hi..

I wanted to use AJAX in my existing website. I refered the Ajax dll and then in my aspx page, i wrote the code as:

<asp:ScripManager ID="ScriptManager1" runat ="server" />

<asp:UpdatePanelID="EditAssoPanel"runat="server">

<ContentTemplate><asp:ButtonID="btnDisplayDestColumn"runat="server"OnClick="btnDisplayDestColumn_Click"Style="z-index: 118; left: 466px; position: absolute; top: 302px"Text="Display Dest Column"Width="176px"/>

</ContentTemplate>

</asp:UpdatePanel>

Is this the correct way to work with AJAX? I am still get the flickering, and i know its not right.. Is there anything else that i should use? please help with working AJAX..

What kind of browser do you use? Some browsers are not yet supported ( if they're not, the page will do a post back instead of partial render). Did you get any javascript error?
I am using Internet Explorer 6, Is the code that i posted earler correct? i didnt get any error. Is there any javascript code to be included

hello note when you use tha ajax control you must"btnDisplayDestColumn_Click out side of the updatepanel and

tha action happend when you click the "btnDisplayDestColumn_Click this action must in updatepanel like loading data to gridview or other

and you must have refrence to ajax control

you must use the other controls with compatibility with ajax


Hi..

Thanks for the reply. But i am sorry, i couldnt understand. Could u please explain with the code i have given

Wednesday, March 21, 2012

Writing a CustomScriptManager

So, I know how to do some of the required code for a "CustomScriptManager", like I postedhere. But there are still some issues that I'm trying to solve, like:

Need to be able to have a corresponding javascript behavior which is automatically referenced on the page (matches the ExtenderControlBase scenario). I assume this has something to do with the EnsureScripts internal method and the various helper methods included in the ScriptReferenceHelper class. I attempted to copy the ScriptReferenceHelper code, but it just wouldn't build.

I also need to be able to use the [RequiredScript] property, again this probably has something to do with the EnsureScripts() mentioned above.

I don't want to use the ExtenderControlBase, because I'm not "extending" anything. I did try it, and just have no properties, but I lose the ability to generate the <customScriptManager id="cManager1" /> in the xml-script.

Any suggestions?

If you would like to write a custom ScriptManager,try to take a look at this reading about asp:ScriptManager to get some ideas.
http://ajax.asp.net/docs/mref/3b24af40-d9f2-7ddd-cb8e-38a9bb90b9c6.aspx
I don't think it is necessary to write a custom ScriptManager if you have installed Ajax framework in your PC.asp:ScriptManager is suitable to most of your development work based on Ajax framework.
Wish this can help you.

XMLHttpExecutor

Hi guys,

I have noticed the following code in the abort function of the Sys.Net.XMLHttpExecutor class:

var a=this._webRequest._get_eventHandlerList().getHandler("completed");
if(a)
a(this,Sys.EventArgs.Empty)

The documentation states that the completed event of the WebRequestManager is raised when the request is completed, timed out or aborted.

Maybe the code should be:

a._webRequest.completed(Sys.EventArgs.Empty);

like in the case when the request is completed or timed out.

Is thig a bug or a feature?

Bogdan

The executor sets the Web request state to aborted. This means that the XMLHttpExecutor Class instance's started Property and aborted Property methods both return true.
Next the WebRequestManager Class instance calls the completed event handler on the associated request object.
After the abort method is called, the state of the response returned by the executor's methods is undefined.
You can call the abort method multiple times. However, the second and subsequent calls are not processed. The completed event handler is raised only once.
You get an exception if you call the abort method before you call the executeRequest Method method.

The unique document?about?Sys.Net.XMLHttpExecutor we can use is from?here?-?http://ajax.asp.net/docs/ClientReference/Sys.Net/XmlHttpExecutorClass/default.aspx
Try to take a look at it and get some ideas from it.

Thank you for your response! Perhaps I didn't make it clear enough .. I agree on what you said about the abort method and what happens if it is called multiple times but my concerns are related to the completedRequest event of the WebRequestManager that is no longer raised in this case.

When a request is timed out the _onTimeout event handler is called and thus the WebRequest's completed event is called:

this._onTimeout=function(){
if(!a._responseAvailable){
a._clearTimer();
a._timedOut=true;
a._xmlHttpRequest.onreadystatechange=Function.emptyMethod;
a._xmlHttpRequest.abort();
a._webRequest.completed(Sys.EventArgs.Empty);
a._xmlHttpRequest=null
}
}

By Calling the completed method of the underlying WebRequest the completedRequest event of the WebRequestManager and also the completed event of the WebRequest are raised and all the registered event handlers notified.

Likewise in the XMLHttpExecutor class when the request completes the same completed method of the WebRequest is invoked:

this._onReadyStateChange=function(){
if(a._xmlHttpRequest.readyState===4){
a._clearTimer();
a._responseAvailable=true;
a._webRequest.completed(Sys.EventArgs.Empty);
if(a._xmlHttpRequest!=null){
a._xmlHttpRequest.onreadystatechange=Function.emptyMethod;
a._xmlHttpRequest=null
}
}
};

Like in the first case the completedRequest event is also raised.

When the request is aborted the completedRequest is not raised any more :

abort:function(){
if(this._aborted||this._responseAvailable||this._timedOut)
return;
this._aborted=true;
this._clearTimer();
if(this._xmlHttpRequest&&!this._responseAvailable){
this._xmlHttpRequest.onreadystatechange=Function.emptyMethod;
this._xmlHttpRequest.abort();
this._xmlHttpRequest=null;
var a=this._webRequest._get_eventHandlerList().getHandler("completed");
if(a)
a(this,Sys.EventArgs.Empty)
}
}
};

What do you think about the above mentioned? Do they represent the correct behavior?

Thanks in advance,

Bogdan


Phew !!

Check out this post:

http://forums.asp.net/thread/1537056.aspx

They have finally realized the bug.. Probably it'll be fixed in the RTM release..

Bogdan