Wednesday, March 28, 2012

ajax beta 1.0 run well in firefox 2.0 , but does not work in IE6 SP1 (winXp or win2000)

I migrate my company website form atlas to ajax beta 1.0 ,but there are script erros in IE6 SP1 (winXP or win2000) when I call web serviece from javascript.the

win2000 OS is updated to SP4 and the winXP OS is updated to SP1,but ajax does not run. when some winXP pc OS is updated to SP2,ajax run well.

By compared, ajax run well in firefox 2.0.

there are many IE users who need my help to run my website ,but who can help me?

Hi,

ASP.NET team member, Chris Riccio has pointed that this problem maybe be caused by a bug in IE 6 SP1 concerning to HTTP compression. In fact, I was able to fix it installing the patch KB912812 on the clients.

AJAX Beta 1.0 - Odd Behaviour of AutoCompleteExtender

Moving to Beta 1.0 has not been a trivial task. I've been using AutoCompleteExtender for a while now and it was working quite well with the CTP. Upgrade to AJAX Beta 1.0 and everything stops working, and this is WITH the Value-Add CTP included as well.

Here is what I ran into:

My webservice method was never being called. I spent 3 hours on trying to figure out why my complex form wasn't calling the webservice when I'd put in a value. Turns out that with the CTP the parameter names on the web method didn't matter, but theyDO matter in beta 1.0.

Originally I had the following signature:

Public Function GetCustomers(ByVal prefixTextAs String,ByVal maxCountAs Integer)As String()
I then switched this this method signature and everything started working:
Public Function GetCustomers(ByVal prefixTextAs String,ByVal countAs Integer)As String()

I then went back and fixed all of my other autocompletes, but one still doesn't work. If you try and use the AutoComplete within a gridview control (I'm trying to let my user add rows by providing a row at the bottom with fields), the control never gets registered for autocomplete.

This used to work in the Atlas CTP. I've tried everything I can think of but no luck fixing this one.

Last thing, when a form has an AutoCompleteExtender and I click on a asp:hyperlink I get an exception thrown by WebResource.axd in the following code:

Sys.UI.DomElement.getVisible = function Sys$UI$DomElement$getVisible(element) {/// <param name="element" type="Sys.UI.DomElement"></param> /// <returns type="Boolean"></returns> var e = Function._validateParams(arguments, [ {name:"element", type: Sys.UI.DomElement} ]);if (e)throw e;return (element.style.visibility !=='hidden');}
The exception thrown is:
Microsoft JScript runtime error: Sys.ArgumentUndefinedException: Value cannot be undefined.Parameter name: element

All in all this has been a pretty frustrating upgrade. The CTP had been working so well for so long that I felt like moving to the Ajax Beta would be a safe proposition...
Charles

Another bugs:

I have AutoCompleteExtender in Wizard control on 3rd step. When I load a page, Javascript error occurs:
1if (!type.inheritsFrom(Sys.Component)) {
2 throw Error.argument('type', String.format(Sys.Res.createNotComponent, type.getName()));
3 }
4if (type.inheritsFrom(Sys.UI.Behavior) || type.inheritsFrom(Sys.UI.Control)) {
5 if (!element) throw Error.argument('element', Sys.Res.createNoDom);
6 }
on line 6 (i code it is line 1960):
Sys.ArgumentException: Value must not be null for Control and Behaviors.
Parameter name: element

I really don't know what to do with it


For us it has been the same. However, changing parameters names does not do the trick...

Can you please provide a short fragement of an ASP page with an AutoComplete that actually works with the new value added package?

Thanks,

J


I am also havin the same problem.I have uninstalled Atlas,installed the Asp.net Ajax and theJuly CTP .I recreated the project with Autocomplete extender but the webservice method is never being called and there are also no errors.

Guimauve, I would appreciate if u can post a sample code on how you made the extender call the webservice method?

Thanks,

PSK


The javascript errors are pretty annoying. Hopefully it wont be long for beta 2 (or beta 1.1?).:-) It is a shame that the CTP was going so well that it feels like a step backwards but they won't have made these changes for nothing and remember we are rather early adopters! If we shouldn't use beta's for production code then CTP is even more risky :-)

For the AutoCompleteExtender make sure your web service has the ScriptService tag as not having it fails silently. E.G:

[Microsoft.Web.Script.Services.ScriptService]
[WebService(Namespace =http://tempuri.org/)]
[WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]


Hi, i have de same Exception (description = "Sys.ArgumentUndefinedException: Value cannot be undefined. Parameter name: element")in WebResource.axd (function Sys$UI$DomElement$getVisible(element)).But my Webservice (or ScriptService) is working fine. I fink the Control is working fine. Everything looks ok, but after Postback (some Applications still need it), pug!Dave
There is a a thread with a sample posted on issue regdin AutoCompleteextenderhttp://forums.asp.net/thread/1437583.aspxIts the same as thx 1137 pointed out

Ajax Beta 1, UpdatePanel and Viewstate issue

Hi all,

I have found what could be a possible bug in the beta 1 regarding the use of the UpdatePanel with postback events.

If we use the update panel and inside it there is a control like a linkbutton that raise a postback, then the event is generated on the server and everything is going on correctly.

In my scenario I have a base page class that overrides the Viewstate load and save methods to compress and decompress it.A simply code that work fine without ajax and with the atlas ctp.(the code put the compressed viewstate content in another hidden field and let the original __VIEWSTATE empty).

With beta1 I've found that with a viewstate compression, this cause the postback events not raised with the right postback value.This happens for example when we click for the second time to the link button, when the viewstate has to be regenerated from the previous click.

I don't know what happens but I think that something has changed in the way the beta1 and UpdatePanel look at the viewstate.

Anyone has had the same issue ?

I just had this problem occur to me this afternoon. Upgraded to the new beta 2 from Atlas and the controls inside my update panels that stored values in ViewState started behaving funny. I too was inheriting from a base class that compressed and cached ViewState. As soon as I took this out and went back to System.Web.UI.Page, the controls worked fine again. This really sucks as we were able to trim so much bloat out of the page by compressing the ViewState. It would be wonderful if MS would consider this.

Forza Milan!


Colt45, to get his scenario working, you would need to explicitly register the hidden field that stores the compressed value of viewstate with ScriptManager, so that the framework would know that it needs to send the updated value for this to the client during an async post-back. I am guessing that you currently use Page.ClientScript.RegisterHiddenField(...) to render your compressed view state. Change this to ScriptManager.RegisterHiddenField(...)

This should fix your issue.

Hope that helps!


Thank you very much, kashif

It works well now...


Sorry...my previous post was wrong...it doesn't work!

I' ve used the ScriptManager.RegisterHiddenField as you suggest but nothing changed.

I need a solution because the viewstate compression is a usefull feature that I don't want to give up, as like as I don't with Ajax...


It did not work for me either.

Most of the problems I see are occuring in GridViews with paging and/or sorting. For example, I have a sorting routine that sorts ASC the first time the header is clicked and then DESC if it is clicked again. The value is stored in ViewState. The first time I click the header, the columns sorts ASC as expected. At this point, "ASC" is stored in ViewState so that when the header is clicked again, I can check this value and then sort by the reverse ("DESC"). However, the grid sorts ASC with every click because the new value is not persisting.

Paging also causes problems. The page data will refresh on the screen correctly between pages 1, 2, 3 etc. However, if I click a button in the 3rd row on the 3rd page that is supposed to update that customer record, it will actually retrieve the customer record that is on the 3rd row of the 1st page. In other words, Ajax always thinks the grid is on the 1st page even though the data on the screen reflects the 3rd page.

If I turn off compressing/caching ViewState, it works fine.
If I leave compression/caching enabled, but turn of Ajax, it works fine.
But together, the marriage fails.


protected override void SavePageStateToPersistenceMedium(Object pViewState)
{
Pair pair1;
System.Web.UI.PageStatePersister pageStatePersister1 = this.PageStatePersister;
Object ViewState;
if (pViewState is Pair)
{
pair1 = ((Pair)pViewState);
pageStatePersister1.ControlState = pair1.First;
ViewState = pair1.Second;
}
else
{
ViewState = pViewState;
}

LosFormatter mFormat = new LosFormatter();
StringWriter mWriter = new StringWriter();

mFormat.Serialize(mWriter, ViewState);
String mViewStateStr = mWriter.ToString();

byte[] pBytes = System.Convert.FromBase64String(mViewStateStr);

pBytes = Compress(pBytes);

String vStateStr = System.Convert.ToBase64String(pBytes);

pageStatePersister1.ViewState = vStateStr;

pageStatePersister1.Save();

//ClientScript.RegisterHiddenField("__MSPVSTATE", vStateStr);

}

protected override Object LoadPageStateFromPersistenceMedium()
{
System.Web.UI.PageStatePersister pageStatePersister1 = this.PageStatePersister;
//try
//{
pageStatePersister1.Load();
//}
//catch
//{
// return null;
//}

String vState = pageStatePersister1.ViewState.ToString();

byte[] pBytes = System.Convert.FromBase64String(vState);

pBytes = DeCompress(pBytes);

LosFormatter mFormat = new LosFormatter();

Object ViewState = mFormat.Deserialize(System.Convert.ToBase64String(pBytes));

return new Pair(pageStatePersister1.ControlState, ViewState);
}


Using ScriptManager.RegisterHiddenField(...) works fine in Beta 2 as long as you set the first argument as an update panel. The update panel can be empty, and should have its UpdateMode set to Always. UsingFiddler you should be able to see your new viewstate hidden field change appropriately.

Whether this is any better or worse than the code in the previous post, I don't know.

Andy

1protected override object LoadPageStateFromPersistenceMedium()2{3string viewState = Request.Form["__VSTATE"];4byte[] bytes = Convert.FromBase64String(viewState);5bytes = Compressor.Decompress(bytes);6LosFormatter formatter =new LosFormatter();7return formatter.Deserialize(Convert.ToBase64String(bytes));8}9protected override void SavePageStateToPersistenceMedium(object viewState)10{11LosFormatter formatter =new LosFormatter();12StringWriter writer =new StringWriter();13formatter.Serialize(writer, viewState);14string viewStateString = writer.ToString();15byte[] bytes = Convert.FromBase64String(viewStateString);16bytes = Compressor.Compress(bytes);17ScriptManager.RegisterHiddenField(this.updVS,"__VSTATE", Convert.ToBase64String(bytes));18}

Hi,

I to am experiencing this problem, i'm using Ajax RC1. I would take the option to use the scriptmanager but i have 2 major problems with this solution, i have a master page that contains the scriptmanager, and i want to apply this to all my existing pages. How can i reference the scriptmanager on the master page from the base class? If at all possible?


Kind regards,

Pedro Costa


Useshunzimm solution above. A slightly modified version of it worked well for me. I have ScriptManager on my master page and it works fine.


This might perhaps be due to changes in the ajax framework, but I've found that you do not need a update panel for ScriptManager.RegisterHiddenField() to work. I just used this as the first param and everything seems okay so far.


Thanks for this post, fixed my issue too with using scriptmanager. One question I have is does it buy anything to have this viewstate compression code on top of IIS 6 HTTP Compression or does http compression make this code obselete?


I've been trying to use the compression code in my application and I'm finding that it's causing problems with a few gridviews that I'm using. What's happening is that the 'OnRowUpdating' and the 'OnRowCancelingEdit' events are not being fired. I have an 'update' and 'cancel' LinkButton inside an 'EditItemTemplate' tag in a 'TemplateField'. The 'OnRowEditing' and the 'OnRowDeleting' events are being fired, but not the other two. Do you have any idea why this might be happening? Any help would be greatly appreciated.

AJAX Beta 1 has forced my pages to US Date format !

Since adding AJAX Beta 1 to my PC all my IIS sites are now showing and requiring dates in MM/dd format instead of dd/MM as they were before.

I have tried:

<globalization culture="en-NZ" uiCulture="en-NZ"/> in by config file and set each page to the same.

Anyone else know why this is and how I can get around this issue ?

Thanks

Matthew Hill

hello.

hum...strange...atals used to have some globalization support but in only influenced client side locale methods. how are you putting the dates on the pages?


I have FormView & GridView controls that display various data from a database. The queries to the database returns the dates as Date fields as per normal but since adding AJAX Beta 1 and the corresponding AJAX Toolkit the dates are showing as MM/dd/yyyy. I set the locale to en-NZ in every page and in the global settings but still they are showing wrong. I also checked my locale settings.

Is it possible that something may be corrupt in the website?

Mat


hello.

though i'm no globalization expert, i think that the problems you're facing are related with ASP.NET and not AJAX extensions. It's really strange that it only has affected your app after adding the extensions...does removing the extensions solve the issue?


Thanks for your reply.

I have tested copying it to another server with AJAX and the dates are around the right way. I still can't figure out why none of the settings are changing the dates back to en-NZ. If I view the site from another PC it is around the wrong way. Argggghhh.

Mat


hello.

quick question: are you pages configured to use localization? if so, are they configured so that they get the values from the browser? if that is tru, then what might be happening is that the browser may be using US culture by default and sending that info back to the site...


I have checked and can't find a US date setting anywhere in IIS, IE7, Regional Settings, Visual Studio, Ajax, Ajax Toolkit. I'm hoping it's not gettings it's settings from the system's Regional properties (the ones created during Windows install) as I don't know how to change them. Also I don't know why they have only just started to effect IIS.

If you visit my website from another PC it shows in US format too, so it is definately an IIS issue.'

Mat


I have checked and can't find a US date setting anywhere in IIS, IE7, Regional Settings, Visual Studio, Ajax, Ajax Toolkit. I'm hoping it's not gettings it's settings from the system's Regional properties (the ones created during Windows install) as I don't know how to change them. Also I don't know why they have only just started to effect IIS.

If you visit my website from another PC it shows in US format too, so it is definately an IIS issue.'

Mat


In ScriptManager's element try to add attribute EnableScriptGlobalizationwith value false:

<atlas:ScriptManagerrunat="server"ID="scriptManager"EnableScriptGlobalization="false"EnablePartialRendering="true"/>

Probaly it's because of your preffered languages in IE7 (as rule there is "English [en-us]").

AJAX Beta 1 error

Hello,

I just downloaded AJAX Beta 1, I have not used any of the previous Atlas version and this is my first stab at Microsoft's AJAX, on my dev machine and on the production machine I consistently get this same error message when a postback should occur from a dropdownlist:

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


I have search high and low on these forums and I can't seem to find a resolution to this. Here is the code on my aspx page that shows the scriptmanager and updatepanel:

<asp:ScriptManager id="scmAddItem" runat="server" EnablePartialRendering="True" />
<asp:UpdatePanel id="pnlCategory" runat="server" UpdateMode="Conditional" RenderMode="Inline">
<ContentTemplate>
Item Base Category : <asp:DropDownList ID="cmbItemCategory" AutoPostBack="true" OnSelectedIndexChanged="cmbItemCategory_IndexChanged" runat="server"></asp:DropDownList><br />
Choose Sub Category <asp:DropDownList ID="cmbSubCategory" runat="server"></asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>

As you can see, I have one dropdown, that when changed should fire the OnSelectedIndexChanged event, but this doesnt seem to happen, I just consistently get the above error message. I copied the sample web.config and placed the dll's in the bin folder with no results.

Anyone come across this before? Any help would be greatly appreciated.

Thanks

Sean

This weekend many people have problems with ASP.NET 2.0 AJAX, thanks Scott Guthrie for releasing something on Friday!

Do you have the problem in every page or just one? Because looks like the project is not set up properly. Got a post about setting up the Atlas projects, however I need to see if still applies to the new ASP.NET 2.0 AJAX (name to long)

http://alpascual.com/blog/al/archive/2006/07/12/Setting-up-Atlas-to-existing-Web-Projects-without-using-the-template-_2800_-Visual-Studio-2005-_2900_-.aspx

Please, let me know if that helps you, if not, I'll update the article with a new set up for ASP.NET 2.0 AJAX ( What about just calling it Atlas?)


Ok,

This is what I have found out so far, If I create a new page, and put my updatepanel in it, it updates properly as expected.

It seems to only be a problem with this one page in peticular where I have a series of complex steps setup, I was trying to add ajax functionality to it and I can't seem to get around the error message I am receiving, i am thinking perhaps it is something with ViewState?

I am doing some more testing now, and I will report back when I find the cause.

Quite strange.


I dont know if it is right solution. I had same problem. If you look at your rendered page so there is in JS method forexample
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tctl00$cphCenter$UpdatePanel1'], [], [], 90); , but no tctl00$cphCenter$UpdatePanel1 object isn't on page. So when i am rendering the page i replace tctl00$cphCenter$UpdatePanel1 with right id ctl00$cphCenter$UpdatePanel1 without t at the begining and there is no error no more.
 
Hope this helps. If not so sorry. 

Well it seems that that T is there rightly. I have read MicrosoftAjaxWebForms.js and found it but for the moment i don't understand it. So sorry

AJAX Beta 1 and PageMethods Error

Hello,
I'm using the PageMethods to call page methods. All works with the ATLAS CTP.
With the new AJAX Beta 1 I have an error: PageMethods is undefined. I don't think it's a problem of my web.config. If i create a new ASP.NET AJAX Enabled Web Site I have the same error.

Someone have the same error? Is it a bug? Is it a beta 1 change?

Thanks,
Alessadro

hello.

make sure that your page method is public and STATIC (this is a change from the previous ctp version). btw, make sure that the method receives all the values that it needs to perform its calculations since now you don't get access to the controls maintained on the page.


I have checked all this things before posting.
My methods are public and static and have the attributes Microsoft.Web.Script.Services.ScriptMethod and WebMethod.
They use only local variables and don't access any page controls.

I think that the error is different: PageMethods is undefined. I have this javascript error, so I don't think it's a problem with my methods. It's the PageMethods that is not defined.
If i define a simple method that return an integer, I have the same error. And I have the same error if i create a new ASP.NET AJAX Enabled web site project too.


hello again.

if i recall correctly, you just need to use the webmethod. here's a quick example i have here:

<%@. Page Language="C#" %>
<%@. Import namespace="LivroAtlas"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
[System.Web.Services.WebMethod]
public static Aluno[] ObtemAlunos()
{
Aluno[] alunos = new Aluno[]{
new Aluno( "João", 15 ),
new Aluno( "Rita", 16 ),
};

return alunos;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="manager" />
<input type="button" value="invocar método da página" onclick="handle()" />
</form>
<script type="text/javascript">
function handle()
{
PageMethods.ObtemAlunos( handleCallback);
}
function handleCallback( res )
{
for( var i = 0; i < res.length; i++ )
{
alert( res[i].Nome + "-" + res[i].Idade );
}
}
</script>
</body>
</html>

btw, if you check the source of your page and don't see the global variable PageMethods, then that means that the ScriptManager is not injecting the proxy for the methods on the client side...


Finally I resolved the problem.
The solution is describe in this post from Shawn Burke's Blog. Due to a bug in this release of AJAX the page method must be in the same ASPX Page and not in codebehind.


Did you do anything to get the PageMethods object to appear on your page?

I've got public static void, I've got WebMethod and ScriptMethod, and I've got the function in the page rather than the code-behind... still nothing.


what the.......

okay... apparently closing the project, leaving it overnight, and changing absolutely nothing... fixed it... what do ya know. :p


This will break too much of my code...I think I will revert back to ATLAS until this is resolved/changed.

AJAX Beta - Undo the changes

It was going so well. Everything worked great, now I have to rewrite my app. Whoever had the idea to require extenders to be in the same panel is fired. This is killing me.

An extender can't be in a different UpdatePanel than the control it extends.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.InvalidOperationException: An extender can't be in a different UpdatePanel than the control it extends.

hello.

well, that's just to guarantee that you don't get orphaned extenders...