Showing posts with label downloaded. Show all posts
Showing posts with label downloaded. Show all posts

Saturday, March 24, 2012

Problem calling Web Service using the DynamicPopulate Extender - Web Service Call Fails: 5

Hi, I'm quite new to ASP.Net AJAX so please forgive my ignorance.

I have downloaded and installed the RC1 version and am following through some of the tutorial videos.

I am having a problem with the Dynamic Populate Extender example. I have created some asp controls with onclick events calling a javascript function. From there I am attempting to use a dynamic populate extender control to call a web service - it's a function declared on that ASPX page as the tutorial explains in necessary and decorated with the System.Web.Services.WebMEthod AND System.Web.Script.Services.ScriptMethod attributes.

Everything works as expected until I attempt to pass a parameter to the web services - in fact until I declare the web service function with a parameter. Once I do this, all that is returned to (or at least all that displays in) the control linked to the DynamicPopulateExtender is "Web Service Call Failed: 500".

Can anyone possibly put me on the right track here? (or would I need to post some code examples?)

Thanks in Advance.

Stu.

the tutorial is in beta version.

i will post my code for you

ASPX page

<%@. Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="DynamicPopulateDemo._Default" %>

<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>

</head>
<body>

<form id="form1" runat="server">
<script type="text/javascript">

function updateDateKey(value) {

var behavior = $find('dpe');

if (behavior) {
behavior.populate(value);
}

}

Sys.Application.add_load(function(){updateDateKey('G');});
</script>

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:DynamicPopulateExtender ID="dpe" runat="server" ClearContentsDuringUpdate="true"
PopulateTriggerControlID="Label1" TargetControlID="pan" ServiceMethod="GetHtml">
</cc1:DynamicPopulateExtender>

<p>
<asp:Label ID="Label1" runat="server" Text="Label" CssClass="subheading">Time at the server:</asp:Label>
</p>
Choose a date/time format:<p>
<label for="r0"><input type="radio" name="rbFormat" id="Radio1" value='G' onclick="updateDateKey(this.value);" checked="checked" />Normal</label><br />
<label for="r1"><input type="radio" name="rbFormat" id="Radio2" value='d' onclick="updateDateKey(this.value);" />Short Date</label><br />
<label for="r2"><input type="radio" name="rbFormat" id="Radio3" value='D' onclick="updateDateKey(this.value);" />Long Date</label><br />
<label for="r3"><input type="radio" name="rbFormat" id="Radio4" value='U' onclick="updateDateKey(this.value);" />UTC Date/Time</label><br />
</p>
<br />
<p>

This time is dynamically formatted and<br /> returned as HTML from the server:

<asp:Panel ID="pan" runat="server" BorderColor="#404040" BorderStyle="Solid" BorderWidth="1px" Height="15px" HorizontalAlign="Center" Width="380px">
</asp:Panel>
</p>

</form>


</body>

</html>

ASPX.CS

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace DynamicPopulateDemo
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
[System.Web.Script.Services.ScriptMethod]
[System.Web.Services.WebMethod()]
public static string GetHtml(string contextKey)
{
System.Threading.Thread.Sleep(250);
string value = string.Empty;

if (contextKey == "U")
{
value = DateTime.UtcNow.ToString();
}
else
{
value = String.Format("{0:" + contextKey + "}", DateTime.Now);
}
return String.Format("<span style='font-family:courier new;font-weight:bold;'>{0}</span>", value);


}
}
}


Thankyou very much for posting this code.

I have worked through the differences between your version of the tutorial and the code I was trying to get running. It all boiled down to the name of the parameter on the web service method. I don't understand this yet but if I call the parameter on my web service method, "contextKey" it works, if I call it anything else, it fails.

Is anyone able to shed some light on this for me?


In the documentation it states that the paramater must be astring namedcontextKey

[WebMethod]string DynamicPopulateMethod(string contextKey) { ... }

Note you can replace "DynamicPopulateMethod" with a naming of your choice, but thereturn type and parameter name and type must exactly match, including case.

Wednesday, March 21, 2012

Problem installing the AJAX Control Toolkit

I tried a search and didn't come up with my key words. I downloaded the ASP.NET 2.0 AJAX Extensions 1.0 and installed it without problems. I can start up Visual Web Developer 2005 Express Edition and now I'm able to choose "AJAX enabled website" from the create website menu.

The problem comes along when I try to install the AJAX Control Toolkit. I watched the second video in the AJAX series regarding how to install the toolkit. The guy unzipped the toolkit file and double clicked on the .sln file. When I do that, VWD opens up but throws up an error message ....

The application for project 'C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\AJAX Control Toolkit\AjaxControlToolkit\AjaxControlToolkit.csproj ' is not installed.
Make sure the application for the project type (.csproj) is installed.

Did anyone come across this issue? I know I can't be the only one.Smile

TIA for your help.Cool

there's no need to install the AjaxControlToolkit. After you unzip the downloaded file, just find the AjaxControlToolkit.dll in their sample folder (Bin) and copy that file to your current Bin folder.


Forgive the ignorance, but what do you mean by the current bin directory? Currently, this is the path on my computer where the website (that I'm developing with VWD Express) resides....

C:\Documents and Settings\Paul\My Documents\Visual Studio 2005\WebSites\Website1\

Under there, there's the App_Data folder, but no bin folder. Do I create a bin folder directly under my folder and just throw in that file? Or would this bin folder that you speak of, somewhere else on the computer? And once I put this file in the right place, the AJAX web controls related to the toolkit will show up in the panel in VWD (I imagine I'd have to restart VWD)?

Thanks in advance.


Never mind, I got the controls to show up on the toolkit panel in VWD Express by adding a tab and adding in the controls referenced by AjaxControlToolkit.dll.Smile They now are accessible in the panel to be used. I will experiment with the new AJAX Controls in a bit.

A question.... when creating a website that I want to incorporate with AJAX, must I choose "ASP.NET AJAX-Enabled Web Site"? Or can I choose either that or the regular "ASP.NET Web Site"? The reason I ask is, all those AJAX related controls are available for me to use regardless of which kind of website I choose at the beginning.

Thanks.

Problem installing the Toolkit

I read the post (http://forums.asp.net/t/1149177.aspx) which pointed to a video to help with the installation.

I downloaded the video and followed the instructions (Create the VSI file in VS 2005; run the VSI) however I am not seeing the toolkit as a template as the video indicates.

I checked the \My Documents\Visual Studio 2005\Templates\ProjectTemplates\Visual C# directory and the AjaxControlExtenderProjectCS.zip file exists within the directory. I am assuming that this should then show up under the 'my templates' section when I click to the web project.

I have checked the options in VS 2005 and for the "Visual Studio user project templates location" it points to the above directory.

It seems like something is simply misconfigured within VS2005 unless there is something else I need to do with the zip file prior to getting this to work.

Thank you in advance.

Hi,

Your configurations are correct.

Please note that the template will be shown in "My Templates" when you select Visual C#, and not listed in any child categories.

Hope this helps.

problem migrate from atlas to ajax

Hi,

I have the folloving problem.

I' ve downloaded sample drag and drop apllication from codeproject.com (http://www.codeproject.com/Ajax/AtlasDragNDrop.asp) and I need to migrate it from atlas to new ajax v1.0beta.

Problem is I didn't find many sample apllictacion in new Ajax and i have problem to rewrite javascript code:

for example:

orginal:

function addFloatingBehavior(ctrl){
var floatingBehavior = new Custom.UI.FloatingBehavior();
floatingBehavior.set_handle(ctrl);
var dragItem = new Sys.UI.Control(ctrl);
dragItem.get_behaviors().add(floatingBehavior);
floatingBehavior.initialize();
}

my try:

function addFloatingBehavior(ctrl){
var floatingBehavior = $create(AjaxControlToolkit.FloatingBehavior,{'handle' : ctrl}, ctrl );
floatingBehavior.initialize();

}

it doesnt work

next scriptmanager in atlas has something like
<atlas:ScriptReference ScriptName="AtlasUIDragDrop" />

in ajax i cann't find replacement

In simple, my problem is add a floatingbehavior to DIV

(DragPanelExtender is not a solution for me)

Thanx for help

Any suggestion?

Please can anybody help me to write simple page with one button. If i click this button - new element (div) is added to page, and this div have to have floatingbehaior.

If I click button again, next div is created and so on...

It have to be in ajax v1.0 beta ...

If you want to see the same apllication in atlas please look at :http://www.codeproject.com/Ajax/AtlasDragNDrop.asp

It′s very urgent. Please help

Thanks Mayo.


I don't have a full answer, but I can tell you the drag and drop I believe is now in the CTP PreviewDragDrop.js file. with the floating behavior being Sys.Preview.UI.FloatingBehavior.