Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

Wednesday, March 28, 2012

Consuming JSON Web Services?

Howdy,

I noticed that Atlas uses JSON to serialize/deserialize objects. Has anyone written an example of the best (most efficient, most elegant) way to consume a JSON Web service from an Atlas application?

(An example of the data I'd be going after is here: http://api.search.yahoo.com/ImageSearchService/V1/imageSearch?appid=jeffreymcmanus&query=bill+gates&results=2&output=json)

If you add "&callback=showResults" to the query, it will come back packaged to pass the JSON data into your custom "showResults" javascript method. Basically, you are getting back a string of client script. It's up to you how you want to handle it in the browser with your own javascript.

At least to me, that's the most elegant way, which is pretty much what you asked.

Peter

Monday, March 26, 2012

ConfirmButtonExtender - how to use ConfirmOnFormSubmit

Hi,

Can anyone please post a working example about how to useConfirmOnFormSubmit property ofConfirmButtonExtender ?

Thanks!

Here is a video tutorial on the extender.

http://www.asp.net/learn/ajax-videos/video-119.aspx


Hi,

I'd say ConfirmOnFormSubmit is either deprecated or was never implemented. I don't see it in my object browser. There's not much out there, other than this documentation which seems to be inaccurate:

http://asp.net/ajax/control-toolkit/live/ConfirmButton/ConfirmButton.aspx

It says:

ConfirmOnFormSubmit - True if the confirm dialog should wait until just before the form submits to display. This is useful when ASP.NET validators are in use and the confirm should be shown only after all validators pass.

Pete


Yes Pete. This is the only information I got from the web search.

I tried many time to use it because my project need to do the validation first and ONLY when the validation passed, we need show the confirmation popup.

Thanks anyway!


Within the Button properties, under theConfirmButtonExtender you must set theConfirmOnFormSubmit to'True'
Only then will the Pop-up only appear if validation has passed true.


Here is my code, the ConfirmOnFormSubmit DOES NOT work. Did I get it wrong? Apprecite your help!
TestConfirmButton.aspx 
<%@. Page Language="C#" AutoEventWireup="true" CodeFile="TestConfirmButton.aspx.cs" Inherits="TestConfirmButton" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %><!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"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> Enter an even number: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator" ControlToValidate="TextBox1" OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator> <br /> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text="Save" OnClick="Button1_Click" /> <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" ConfirmText="Warning!"ConfirmOnFormSubmit="true" TargetControlID="Button1" Enabled="True"> </ajaxToolkit:ConfirmButtonExtender> <br /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></div> </form></body></html>

TestConfirmButton.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;public partialclass TestConfirmButton : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { Label1.Text =""; Label2.Text =""; }protected void Button1_Click(object sender, EventArgs e) { Label1.Text ="Saved!";// Display whether the page passed validation.if (Page.IsValid) { Label2.Text ="Page is valid."; }else { Label2.Text ="Page is not valid!"; } }protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) {try {// Test whether the value entered into the text box is even.int i =int.Parse(args.Value); args.IsValid = ((i % 2) == 0);//args.IsValid = false; }catch (Exception ex) { args.IsValid =false; } }}

Correct me, but are you trying to use the 'ConfirmButtonExtender' as a popup for the validation of the even number?


I just used the evaluation of the even number as an example to use the ConfirmButtonExtender's ConfirmOnFormSubmit.

The thing I wanted to achieve is:

The confirm message popups only when the number is even; if the number is odd, then don't popup the confirm message.

Is this do-able at all?

Thanks!


Hi,

The ConfirmOnFormSubmit property indicates that the ConfirmMessage will popup when the page is to be submitted. So, only the failure of client side validation( That's to say, you need to enable clientValidation for this customValidator. ) is able to prevent the form from being submitted, subsequently the ConfirmMessage won't be shown.

Now consider your situation, the confirm box has to be shown when the validation fails, which means the form isn't able to submit. It's a paradox. You may need to implement it withconfirm method.

Hope this helps.

Saturday, March 24, 2012

Conditional ConfirmButtonExtender

Hi!!

Just wondering if this was possible...

I've got some buttons that sometimes I want to confirm, and at other times I don't. For example, if I'm taking an order for a certain quantity (e.g. 1,000) I might want to confirm that the user is happy with this, whereas if it's for a low amount (e.g. 1 or 2) I don't need to confirm this.

Has anyone got any ideas how to achieve this with the confirmButtonExtender, or is it a case of writing manual javascript and using the OnClientClick property of the asp:Button?

Many thanks in advance for your help!

Regards,

James

I'm thinking you might modify a customized ConfirmButton slightly so that it knows to look at some page state (JS variable, element value, etc.) before displaying the confirm dialog. Shouldn't be much more than an additional line or two, I'm not thinking...

Wednesday, March 21, 2012

componenet alike dragpanel

hi everybody, i want create some component(for example : label, textbox,..) alike dargpanle's ajaxtoolkit( i can drag them). but i dont know how can i do it?

Hi MarziehReader,

To create an extender , I would like to introduce thisdocument. To create a DragPanelExtender , you should dip into its source code since the AJAX Control Toolkit is an open source project.

Best regards,

Jonathan

complex webservices with ajax beta 1

Is there an example of a complex webservice with the beta version of ms ajax? I can't get it to work like the previous version did. I returned a class A in a webservice, where class A has a public class B field. In the generated javascript proxy, there's no reference to class B whatsoever. Am I missing something? Are there some examples I'm missing?

The generated javascript proxy just include top-level classes, i.e., does not recurse into the types.
If you need to include class B in the generated javascript proxy, you need to apply the Microsoft.Web.Script.Services.GenerateScriptTypeAttribute on your web service definition or web method definition.

I hope that helps.

Maíra