Wednesday, March 28, 2012
AJAX becomes full postback in IIS
<div>
<asp:UpdatePanel ID="upnlServerTime" runat="server">
<ContentTemplate>
<asp:Label ID="lblServerTime" runat="server" Text="Server Time"></asp:Label>
<asp:Button ID="btnServerTime" runat="server" Text="Get Server Time" OnClick="btnServerTime_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnServerTime" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
Behind Code:
protected void btnServerTime_Click(object sender, EventArgs e)
{
Label lblServerTime = upnlServerTime.FindControl("lblServerTime") as Label;
lblServerTime.Text = DateTime.Now.ToLongTimeString();
}
I doubt you don't create web application when you create a virtual directory in IIS.Right mouse click virtual directory in IIS and select Properties,Click "Create" button to create application name and Choose Execute Permission for "Scripts only" or "Scripts Executable" from permission DropDownList.Try to addNetwork Service to virtual directory?when?deploying?Ajax?
website.
Wish this can give you some ideas.
Monday, March 26, 2012
Ajax AutoComplete Problem
I have been trying to get the AutoComplete work without success. (many Days)
I have a deveplement Server 2003, XP workstation with VS2005 and IE7, and have check this with a workstation with Win98&IE6
I am using the demo from the Ajax.net video's
I have install the lastest ajax onto the server and the bin directory has: AjaxControlToolkit;AjaxControlToolkit.dll;AjaxControlToolkit.dll.refresh;AJAXExtensionsToolbox.dll;BuildVsi.dll;JavaScriptCommentStripper.dll;System.Web.Extensions.Design.dll;System.Web.Extensions.dll;Tools.dll;Tools.netmodule.
I can get things like the CollapsiblePanelExtender working, The demo on the ajax web site works.
The page displays as expected, but when I type the 3rd character, nothing happens
Filddler gives me an error 500, on the 3rd 'a'
I also had to create a folder named 'GetCompletionList' with a copy of autocomplete.asmx in it to fix an error 404 that fiddler gave me, which may be anther issuse.
I can call the web service and get results from it and '/js' gets me the option to download the JavaScript.
=====Fiddler=====
{"prefixText":"aaa","count":10}
-----------
HTTP/1.1 500 Internal Server Error
Date: Sun, 29 Apr 2007 10:35:28 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 1666
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Receiver</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable to process request. --> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read()
at System.Xml.XmlReader.MoveToContent()
at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.MoveToContent()
at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement()
at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
-- End of inner exception stack trace --</soap:Text></soap:Reason><soap:Detail /></soap:Fault></soap:Body></soap:Envelope>
=====Default.aspx=====
<%
@dotnet.itags.org.PageLanguage="VB"AutoEventWireup="true"CodeFile="Default.aspx.vb"Inherits="_Default" %><%
@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %><!
DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><
htmlxmlns="http://www.w3.org/1999/xhtml"><
headrunat="server"><title>Ajax Test</title></
head><
body><formid="form1"runat="server"><asp:ScriptManagerID="ScriptManager1"runat="server"><Services><asp:ServiceReferencePath="AutoComplete.asmx"/></Services></asp:ScriptManager><asp:TextBoxID="TextBox1"runat="server"></asp:TextBox><br/><cc1:AutoCompleteExtenderid="AutoCompleteExtender1"runat="server"ServiceMethod="AutoComplete.asmx"ServicePath="GetCompletionList"TargetControlID="TextBox1"></cc1:AutoCompleteExtender></form></
body></
html>
=====AutoComplete.asmx=====
<%
@dotnet.itags.org.WebServiceLanguage="VB"CodeBehind="~/App_Code/AutoComplete.vb"Class="AutoComplete" %>
=====App_Code/AutoComplete.vb=====
Imports
System.WebImports
System.Web.ServicesImports
System.Web.Services.ProtocolsImports
System.Collections.Generic'from line 10( before ScriptService): <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<WebService(Namespace:=
"http://tempuri.org/")> _<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<System.Web.Script.Services.ScriptService()> _
Public
Class AutoCompleteInherits System.Web.Services.WebService<WebMethod()> _
PublicFunction GetCompletionList(ByVal prefixTextAsString,ByVal countAsInteger)AsString()Dim c1AsCharDim c2AsCharDim c3AsCharIf (count = 0)Thencount = 10
EndIfDim rndAsNew Random()Dim itemsAsNew List(OfString)For iAsInteger = 1To countc1 =
CStr(rnd.Next(65, 90))c2 =
CStr(rnd.Next(97, 122))c3 =
CStr(rnd.Next(97, 122))items.Add(prefixText + c1 + c2 + c3)
Next iReturn items.ToArray()EndFunctionEnd
Class
=====Web.config=====
<?
xmlversion="1.0"?><
configuration><
configSections><
sectionGroupname="system.web.extensions"type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"><
sectionGroupname="scripting"type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"><
sectionname="scriptResourceHandler"type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication"/><
sectionGroupname="webServices"type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"><
sectionname="jsonSerialization"type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="Everywhere"/><
sectionname="profileService"type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication"/><
sectionname="authenticationService"type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication"/></
sectionGroup></
sectionGroup></
sectionGroup></
configSections><
system.web><!--
MarkRoss: Next line added to fix remote error message--><
customErrorsmode="Off"/><
webServices><
protocols><
addname="HttpGet"/><
addname="HttpPost"/></
protocols></
webServices><
pages><
controls><
addtagPrefix="asp"namespace="System.Web.UI"assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></
controls></
pages><!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
--><
compilationdebug="false"><
assemblies><
addassembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><
addassembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/><
addassembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies></
compilation><
httpHandlers><
removeverb="*"path="*.asmx"/><
addverb="*"path="*.asmx"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><
addverb="*"path="*_AppService.axd"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><
addverb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"validate="false"/></
httpHandlers><
httpModules><
addname="ScriptModule"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></
httpModules></
system.web><
system.web.extensions><
scripting><
webServices><!--
Uncomment this line to customize maxJsonLength and add a custom converter--><!--
<jsonSerialization maxJsonLength="500">
<converters>
<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
</converters>
</jsonSerialization>
--><!--
Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate.--><!--
<authenticationService enabled="true" requireSSL = "true|false"/>
--><!--
Uncomment these lines to enable the profile service. To allow profile properties to be retrievedand modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and
writeAccessProperties attributes.
--><!--
<profileService enabled="true"
readAccessProperties="propertyname1,propertyname2"
writeAccessProperties="propertyname1,propertyname2" />
--></
webServices><!--
<scriptResourceHandler enableCompression="true" enableCaching="true" />
--></
scripting></
system.web.extensions><
system.webServer><
validationvalidateIntegratedModeConfiguration="false"/><
modules><
addname="ScriptModule"preCondition="integratedMode"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></
modules><
handlers><
removename="WebServiceHandlerFactory-Integrated"/><
addname="ScriptHandlerFactory"verb="*"path="*.asmx"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><
addname="ScriptHandlerFactoryAppServices"verb="*"path="*_AppService.axd"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><
addname="ScriptResource"preCondition="integratedMode"verb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></
handlers></
system.webServer></
configuration>I have resolved this
in:-
<cc1:AutoCompleteExtenderid="AutoCompleteExtender1"runat="server"ServiceMethod="AutoComplete.asmx"
ServicePath="GetCompletionList"TargetControlID="TextBox1">
</cc1:AutoCompleteExtender>
I had theServiceMethod& ServicePath attributes back to front
Note: Using Fiddler helped, couldn't see this problem initially due to its simplicity
"I also had to create a folder named 'GetCompletionList' with a copy of autocomplete.asmx in it to fix an error 404 that fiddler gave me, which may be anther issuse."
AJAX and WebApplication Project Type
I have a VS2003 Web project I converted to VS2005 sp1 WebApplication project (not WebSite project). I wanted to add AJAX to this web application so I followed the directions outlined in the video on the AJAX site. I added all the entries to the web.config without any trouble. I added the ScriptManager control to one of the pages and an UpdatePanel. I also had to set a reference tosystem.web.ui. System.Web.Extensions However, when I try to drag some of the asp.net controls already on the page (drop down boxes) to the update panel, it does not seem to be accepting them. They are not "dropping into" the update panel. The panel does not highlight when I drag the controls over it.
What am I missing?
EDIT: The reference I set was System.Web.Extensions...not web.ui.
Apart from working with the Designer, have you tried working around in the HTML to see if its working?
Wrap your controls with the UpdatePanel and see if the page is working.
-Thanks
It's hard to tell without seeing the web.config, etc. The easiest way (and the method I used) is to create a new project, and view the differences between the web.config files and references.
I copied all of my project-specific settings (the ones that I added myself) to the web.config for the new project, then copied the resulting file to my actual upgraded project. It worked for me!
Just be sure to make backup copies of the old web.config, just in case you need to revert.
ravivb.net:
Apart from working with the Designer, have you tried working around in the HTML to see if its working?
Wrap your controls with the UpdatePanel and see if the page is working.
-Thanks
I have not tried that appraoch yet, however I will give it a try. thank you for your response.
ps2goat:
It's hard to tell without seeing the web.config, etc. The easiest way (and the method I used) is to create a new project, and view the differences between the web.config files and references.
I copied all of my project-specific settings (the ones that I added myself) to the web.config for the new project, then copied the resulting file to my actual upgraded project. It worked for me!
Just be sure to make backup copies of the old web.config, just in case you need to revert.
I will give this a try. I originally did it the other way around (copied web.config entries from the emtpy project to my project). Thank you for the response.
wjdunn3:
ravivb.net:
Apart from working with the Designer, have you tried working around in the HTML to see if its working?
Wrap your controls with the UpdatePanel and see if the page is working.
-Thanks
I have not tried that appraoch yet, however I will give it a try. thank you for your response.
This approach worked. I added the Script Manager and Update Panel to the Page then switched to HTML view. I moved the Script Manager tags to be just under the first FORM tag. I wrapped the code I wanted in the Update Panel tags and *important part* ContentTemplate tags.
I don't know why it does not work within the designer...I will have to try and figure that out another day. Thanks all for the quick responses.
Wednesday, March 21, 2012
Ajax and debugging. Is Edit & Continue possible?
Hi!
I'm a newbie in Ajax. I'm using VS2005 and vb.net in AJAX project.
Is it possible to debug and modify the source code (edit & continue).
Because I can't!
Can you help me?
Thx!
Yes if you use ASP.NET WebApplication project instead of a web site project you will be able to use edit and continue. To create a new ASp.NET AJAX web application project you need to have VS 2005 SP1. You can create a new web application from the New Project Dialog.