Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Wednesday, March 28, 2012

very basic question about the atlas samples

I went thru the instructions exactly (well almost...the create new item for the webservice in VS2005 is incorrect in the tutorial, it should be Create new website)

http://atlas.asp.net/docs/Walkthroughs/GetStarted/Basic.aspx

But i keep getting aError: Samples is undefined

I tried this in an attempt to fix it..but it failed too (this URL i put in the Start URL in the webservice)..I wasnt sure

<atlas:servicereferencepath="http://localhost:1169/AtlasWebService/HelloWorldService.asmx"/>

What dumb thing am i missing?

Thanks!

What do you get when you go tohttp://localhost:1169/AtlasWebService/HelloWorldService.asmx/js

Executing:

http://localhost:1169/AtlasWebService/HelloWorldService.asmx/js

Gives:

Server Error in '/AtlasWebService' Application.


Request format is unrecognized for URL unexpectedly ending in '/js'.


That is why you are getting the 'undefined Samples' javascript error. Atlas will generate the javascript objects for your webservice if you have it configured correctly. Using /js after your webservice is a good way to test if this is working.

I would recommend taking the following steps to debug this issue:

1) Double check that you are using the April CTP of Atlas. You may want to uninstall your current version and re-install the version found by going to http://atlas.asp.net/ and clicking the 'Download' button.

2) When you create your website, make sure the template you select is called _"Atlas" Web Site_. This template will give you a web.config to start from that has the appropriate configuration settings to enable generation of javascript for your web service.

3) Follow the steps in the walkthrough to create the web service. Note that the instructions are correct. Make sure you right-click on the web project (not the solution) and select 'Add New Item'. Web Service will be one of the options.

4) Test your web service by setting it as the start page and pressing F5. You should get the standard web service test page - click on the web service and make sure it works. If it does, then add '/js' to the path and see if Atlas generates javascript.

5) Follow the steps in the walkthrough to create the test page.

My guess is that your problem is caused by a configuration error. By following the steps above, you should discover what was causing the problem.
Regards,
Kyle

I'm going to assume you are using one of the wallkthroughs like this one,"Walkthrough: Creating a Basic ASP.NET 'Atlas' Web Application"

I ran into this same problem you did and the fix went like this:

When i created the new "Atlas Website", i right clicked on the root and chose "Add New", then "WebService", and put "HelloWorldService.asmx"

This did two things:
- Created "HelloWorldService.asmx" in the root of the directory
- Created "HelloWorldServer.vb" in the App_Code directory

I had then copied and pasted the code right from the sample walkthrough into the VB file....

But here was the catch, and the cause of the problem:
- The sample has "Namespace Samples.Atlas" or something the like wrapped around its classes

- Well, back on the asmx, it had put:
<%@. WebService Language="VB" CodeBehind="~/App_Code/HelloWorldService.vb" Class="HelloWorldService" %>

- And since we had just changed the classes namespace since we copied and pasted from the code on the walkthrough, we broke the link between the two, hence the "Samples in undefined" error

So my fix was to change the asmx file to say

<%@. WebService Language="VB" CodeBehind="~/App_Code/HelloWorldService.vb" Class="Samples.Atlas.HelloWorldService" %>

Problem = solved


Thanks Kyle, it was my error that i didnt read the docs closely enough...i had passed by the right click on the atlas website, and created a asp.net webservice thru the right click new webservice on the solution.

I assume that i can do the latter, later, by manually copying the relevant config entries for Atlas into the non-Atlas asp.net web.config...

thanks again

Very Basic Static Method Question - SlideShowExtender

I'm working with the SlideShowExtender to show slides from a database. I have everything working as planned, except for a major oversight which I can't figure out how to get around properly. Internally I am housing a static SlideList object which contains all the slides returned from my DAL. Inside my

static AjaxControlTookit.Slide[] GetSlides() method I am copying the SlideList interal objects into the Slide[] object and then returning it. Now for my problem, naturally because my SlideList is static, there is only one copy across each page. When more than one user is on the website at the same time, obviously they are touching the same slideshow data which is causing a lot of problems. What is the correct way to handle this solution? Was I supposed to place the GetSlides() method in a WebService.asmx webservice, or is it ok to keep them as PageMethods and then correctly keep track of the Slides on a per page basis?

I would rather keep the GetSlides() method as a static PageMethod so I don't have to completely refactor the entire project, however I am not sure how I would correctly go about having Slides and then accessing them within my static methods. I realize this is a very elementary problem, and I feel awfully silly for not knowing the answer!

THanks!

Hi,

Your question is how to return different slides upon different requests, isn't it?

Well, you may pass a parameter (contextKey) into the GetSlides method, and use it to filter some slides.

For example, let's say you plan to filter the slides according to the userName of the one is browsing the page, you assign current user name in Page_Load.

protected void Page_Load(object sender, EventArgs e)
{
this.slideshowextend1.ContextKey = currentUserName;
}

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static AjaxControlToolkit.Slide[] GetSlides(string contextKey)
{ // return a slide array according to contextKey
}

Hope this helps.

ViewState in Session is still uploaded after AsyncPostBack

Hi all,

Here is the basic setup of my page.

- ViewState stored in session
- AutoCompleteExtender using a WebService
- UpdatePanel triggered by button next to AutoComplete TextBox

Here is the behavior I'm experiencing (note that I have validated this with Fiddler):

Page loads first time. "id="__VIEWSTATE" value="y0V/cubnEZ1qzAvIgW0oRpVSc8AvJU6rtssTVFt7+B8="
ViewState is short as expected because storing it in the session.

Now, I click on the button to activate the UpdatePanel, causing a partial postback. This takes much longer than expected. After inspecting with Fiddler I see that it is uploading 50K. I inspect the Request and notice that most of it is my ViewState (I have a repeater on the page). I even turned EnableViewState off on the Repeater and it still uploads it.

My questions are:

1. Where is this uploaded ViewState coming from? It was not downloaded, is it generated clientside by JavaScript?
2. How can I stop this ViewState from being uploaded?

Regards,
Cole

I now realize this is not the viewstate but all of the form elements names & values being concatenated together. Is there a way to adjust what gets sent back from the controls on a AsyncPostBack?


The only way I'm aware of is to not use updatepanels to traffic your info, but instead to use web services, page methods, or hand-jam your own webrequest.

Monday, March 26, 2012

Visual Basic Examples Echo Name on web and in documentation down load does not work

I have done a clean reinstall of Visual Studio 2005, the SP1, The vs2005 Vista Update (Home Premium Vista), and IE 7.00..

One of the four Simple Web Service examples in the documentation download did not work, and as Mr. Murphy acknowledges, it's the one I am interested in.

I made sure not to touch any code .. just install and then debug..

http://localhost:49160/aspDocumentation/Samples/Sys.Net.SimpleWebService/vb/SimpleWebService.aspx

did not echo

This example also does on work on theasp website.

http://localhost:49160/aspDocumentation/Samples/Sys.Net.PageMethod/vb/PageMethod.aspx

did echo

http://localhost:49160/aspDocumentation/Samples/Sys.Net.SimpleWebService/cs/SimpleWebService.aspx

did echo

http://localhost:49160/aspDocumentation/Samples/Sys.Net.PageMethod/cs/PageMethod.aspx

did echo

Thanks!




Hi,

Can you tell me which documentation are you referring to?

Look forward to your reply.


http://ajax.asp.net/docs/tutorials/ExposingWebServicesToAJAXTutorial.aspx

Simple Echo works in C# but not in VB


Can you be more specific about your vb sample doesn't work? And how is it related to Vista?

It will be better if you canshow me a sample.


1. Go tohttp://www.asp.net

2. Click on AJAX.

3. You are now at the page titled:

"AJAX: The Official Microsoft ASP.NET AJAX Site

4. Click on "Docs"

5. Click on "Open The Online Documentation"

6. On The ASP.Net AJAX Roadmap page go to the fifth section titled "Web Services" and click

on the second item "Exposing Web Services To A Client Script"

7. On the top right side of the page select C# as the "Preferred Sample Language"

8. Go to the middle of the page to the paragraph that is titled:

Exposing Web Services to Client Script in an ASP.NET Web Page

9. At the bottom of the paragraph are two buttons, a run it button and a script button.

10. Click on Orange Button "Run It"

11. Enter your name and click on echo

12. close the "Simple Web Service" window

13. You have returned to the Exposing Web Services to Client Script in an ASP.NET Web Page

14. On the top right side of the page select Preferred Sample Language and select Visual Basic

15. Click on the same "run it" option that you did in step 10.

16. Enter your name and click on echo

17. Nothing happens.. Why?


Thanks for your clear explanation.

Now I've noticed it too, and I copy and paste the vb source code into a local project, it works.

And this sample should already give you an idea of how to expose webservice to client side.


You must be doing something in your local project setup, or your config file, or something.. why doesnt it work on the web?

In addition, when you download the "tutorial" the example, like the web, it does not work. Why?

If Microsoft has a "official" AJAX tutorial, one would think their examples would work. At least I think they should work..

Why does the C# example work and the VB example not work?

Could you locate the group that put together this "example" and tell them it doesnt work?

Thanks


Thanks for your feedback. I have checked the document and I found thatthe service entry registered in the ScriptManager has a invalid path.

<asp:ScriptManager runat="server" ID="scriptManager">
<Services>
<asp:ServiceReference path="SimpleWebService_VB.asmx" /> <%--should be SimpleWebService.asmx--%>
</Services>
</asp:ScriptManager>

To feedback this document issue in a formal way, could you go to our Connect portal site and submit it? http://connect.microsoft.com/ Every feedback submitted will be evaluated carefully by our engineers and document writers. They will let you know their comments further through that portal. It would be great if you can also paste the link to the submitted feedback here, so that other community members can see it as well.

walkthrough problems

I have just completed my first Atlas Walkthrough using Visual Web Developer 2005 Express Edition . I choseWalkthrough: Creating a Basic ASP.NET 'Atlas' Web Application.There were a few places where I floundered.

I accidently copied both the [Visual Basic] and [C#] code fragments. Perhaps there could be a sentence dividing them.

I didn't find the following instruction very clear:

"Add a new ASP.NET page to your project and name it AtlasScript.aspx.

Note Be sure that you clear thePlace code in separate file check box. For this walkthrough, you must create a single-file ASP.NET Web page."

Compare it with the earlier precise instructions:

"In Solution Explorer, right-click the name of the site, and then clickAdd New Item.

In theAdd New Item dialog box, underVisual Studio installed templates, selectWeb Service.

Name the file HelloWorldService.asmx and clear thePlace code in separate file check box.

Select the language you want to use.

ClickAdd."

At the end, I was unsure how to run theAtlasScript.aspx page. Through trial-and-error I right-clicked the AtlasScript.asx in Solution Explorer and chose "View in Browser".

Then the script wouldn't work. There were two problems.

The first I solved by changing the functionDateTime.Now toDate.Now. This needs to be changed in the walkthrough instructions.

The other problem was that you cannot pressEnter on the keyboard, you have to click theSearch button. It is almost subconsciously-automatic to press Enter, so it would be better if it was enabled.

I have not completed my first Atlas Walkthrough using Visual Studio 2005. My experiences are similar to yours with the difference that I get stopped at the error message: Validation (XHTML 1.0 Transitional): Element 'title'occurs too few times. Error occurs in AtlasScript.aspx line 7 containing <head id="Head1" runat="server">. Any idea?

asalisse

Wednesday, March 21, 2012

Web App Projects and ScriptManager/UpdatePanel

I am VERY new to this so please excuse me for this obvious question. I have started a basic web app project in VS2005. Just a button, label and textbox. Wors fine. If I drop a scriptmanager and update panel on the page and move the three controls to the update panel I get a scripting error that 'Sys' is not defined. The error is in the page source script shown below:

Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('form1'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tUpdatePanel1'], [], [], 90);

Is there a way to prevent this or edit the script that the script manager produces so as to not throw the error?

Thanks

Hi ixis,

You will have to use the "ASP.NET-Enabled Web Site" template instead of the "Empty Web Site" when creating a new Ajax application so that http handlers and modules are registered in your web.config. Here's an example of an Ajax-Enabled Web Site's web.config:


<configuration> <configSections> <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/> <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" /> <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" /> <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" /> </sectionGroup> </sectionGroup> </sectionGroup> </configSections> <system.web> <pages> <controls> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </controls> <tagMapping> <add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="System.Web.UI.Compatibility.CompareValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="System.Web.UI.Compatibility.CustomValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="System.Web.UI.Compatibility.RangeValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="System.Web.UI.Compatibility.RegularExpressionValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="System.Web.UI.Compatibility.RequiredFieldValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="System.Web.UI.Compatibility.ValidationSummary, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </tagMapping> </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. --> <compilation debug="false"> <assemblies> <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </assemblies> </compilation> <httpHandlers> <remove verb="*" path="*.asmx"/> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add verb="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> <add name="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 retrieved and 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> <validation validateIntegratedModeConfiguration="false"/> <modules> <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </modules> <handlers> <remove name="WebServiceHandlerFactory-ISAPI-2.0"/> <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add name="ScriptResource" verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </handlers> </system.webServer></configuration>

Thanks, I'll give that a try. Just to note because I wasn't very clear in my original post, if I create a normal ASP.NET Website project, the UpdatePanel works just fine. If I create a Web Application Project using the Visual Studio 2005 Web Application Project Model I have the problem. I'm not saying your solution isn't what I am looking for just clearing up the original question. I am certainly going to review my web.config as per your post.

Web DateTimePicker

It seems strange but till now no such basic control has been made part of a web standard toolbox. It is easy to find and there are plenty of them calendards, time controls but no an integrated control that incorporates both.

Sure such control could be developed and no doubts. I am referring to this not from a pure developing point of view but from a end customer's. I need such control and I would prefer to use an standard control and not having to add additional user or thid-party controls

Hi,

There is a Calender control in standard toolbox, please refer to these documentations for more information:

http://msdn2.microsoft.com/en-us/library/tc52hey5.aspx

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.calendar(vs.80).aspx


I am not referring to a Calendar....

What is missing is a DateTime picker


I'm afraid this is the only control in standard toolbox currently.


Raymon,

I am raising this because I believe that Microsoft should provide a similar control to the one provide under windows, I know that there are 3rd paty controls and I will have to use one of them or build my own, but that is not the point I am stressing.

What I am asking is to include such control for future versions of ASP.NET, hopefully one of the guys at Microsoft take the suggestion on board...


The most efficient way to submit a suggestion is create an item here[http://connect.microsoft.com/VisualStudio]. Thanks.

Web Server Controls - Basic Requirements To Work with AJAX.NET

Is thereany documentation showing what is required to equip a server-side WebControl to work with AJAX.NET?

I have some VERY simple WebControls that fire "Click" events. One of them consistantly causes the entire page to refresh, while the other doesn't. But they are both doing the same thing. For some reason, one seems tonot work with AJAX.NET, while the other does. Both of them are wrapped inside an UpdatePanel and ContentTemplate - but behave differently under AJAX.NET. Mysterious.

I can't tell if the examples showing ScriptControlDescriptor.AddEvent are relevent for what I'm doing or not. This seems to be related to very specific client side javascript voodoo - I just want to have a generic control that can fire events that will postback to the code-behind (like a normal ASP.NET button, for example - I can drop one of these on a page, use the event, and it just works - but how to do this properly with a custom WebControl - RELIABLY?).

If there is a plain-jane, simple example of a WebControl and the proper way to have it fire events (__doPostBack) without causing the entire page to refresh, that would be VERY helpful.

Thanks.

There's lots of examples of how to do this outside the webcontrol, so to do it inside a webcontrol all you really have to do is embed the javascript in the assembly and make sure that it ends with the if(Sys && Sys.Application) Sys.Application.notifyScriptLoaded(); statement. The easiest way to wire up interaction between your C# class and the javascript is by following the pattern described in the tutorials on custom extenders. children of ScriptControl follow the same basic pattern.

I've looked at the examples. There are too many things illustrated just aren't exlained. Sorry. I just don't have time to read the "Gone With the Wind" to get an answer to a simple question.

Do I have to write special javascript beyond the standard "_doPostBack" to get a postback executed without causing a page update? Why does it work for an asp:Button without doing anything out of the ordinary? Is some kind of magic support wired into ASP.NET for the standard .NET controls?

SIMPLE QUESTION (YES/NO):

Can I write a WebControl that fires events - like I would for a NON-AJAX application - and have it work under AJAX.NET without refreshing the entire page?

I thought that any postbacks generated inside an UpdatePanel/ContentTemplate would be AUTOMATICALLY handled by AJAX.NET. This is what it says in the documentation. Is this true or no?

This is just a YES/NO question.

Thanks (frustrated - about to punt on AJAX.NET and just work with web callbacks...)