Great answer, Albert...! I was some minutes to slow, was cutting my hairs.  ;)

Regards,
Michael



On 5/19/06, Albert Weinert <[EMAIL PROTECTED]> wrote:
>
> [EMAIL PROTECTED] schrieb:
>
> > Hello... i want to get the out string to ClientSide code with AjaxPro2
> > (I use .NET 2.0)
> >
> > My code is like following
> >
> > ============ ASPX file :: START ============
> >       [AjaxPro.AjaxMethod]
> >       public DataSet GetDS(out string Error)
> >       {
> >               try
> >               {
> >                       DataSet ds = new DataSet();
> >                       //generate error
> >                       ...
> >                       return ds
> >               }
> >               catch (Exception err)
> >               {
> >                       Error = err.ToString();
> >                       return (new DataSet());
> >               }
> >       }
>
> Ajax.NET Pro has built-in exception Handling, it passes the exception to
> the  client.
>
>        [AjaxPro.AjaxMethod]
>        public DataSet GetDS()
>        {
>                DataSet ds = new DataSet();
>                //generate error
>                ...
>                return ds
>        }
>
>
> // Client
>
> function getDS()
> {
>      this._Default.GetDS(getDS_callback1);
> }
> function getDS_callback1(res)
> {
>        if (res.error != null)
>        {
>                alert(res.error.Message);
>        } else
>        {
>                var dataSet = res.value;
>        }
> }
>
> If you want to return more than one Information you can build an little
> Class for that.
>
> // Server
> public class DataSetResult
> {
>        private string error;
>        public string Error
>        {
>                get { return error;}
>                set { error = value;}
>        }
>        private DataSet dataSet;
>        public DataSet DataSet
>        {
>                get { return dataSet;}
>                set { dataSet = value;}
>        }
> }
>
>        [AjaxPro.AjaxMethod]
>        public DataSetResult GetDS()
>        {
>                DataSetResut dsr = new DataSetResult();
>                try
>                {
>                        DataSet ds = new DataSet();
>                        //generate error
>                        dsr.DataSet = ds;
>                }
>                catch (Exception e)
>                {
>                        dsr.Error = e.ToString();
>                        dsr.DataSet = new DataSet();
>                }
>                return dsr;
>        }
>
>
> // Client
>
> function getDS()
> {
>      this._Default.GetDS(getDS_callback1);
> }
> function getDS_callback1(res)
> {
>        if (res.error != null)
>        {
>                alert(res.error.Message);
>        } else
>        {
>                var dataSet = res.value.DataSet
>                var errorMessage = res.value.Error;
>        }
> }
> --
> Freundliche Grüße
>
> Albert Weinert
>
> http://der-albert.com
>
> >
>


-- 
Best regards | Schöne Grüße
Michael

Microsoft MVP - Most Valuable Professional
Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz/
http://www.schwarz-interactive.de/
mailto:[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at 
http://www.ajaxpro.info
-~----------~----~----~----~------~----~------~--~---

Reply via email to