I have been trying these examples at
http://www.ajaxpro.info/Examples/Special/controls.aspx

but doesn't seem to work.
I keep getting the error "WebUserControl1 is not defined"
Any ideas?

I have a webform1.aspx page with

<uc1:WebUserControl id="mycontrol" runat="server"></uc1:WebUserControl>
and the control registered:-
<%@ Register TagPrefix="uc1" TagName="WebUserControl"
Src="WebUserControl1.ascx" %>

In the WebUsercontrol.ascx i have  :-
<script type="text/javascript">

//MyDemo._Default.GetServerTime(getServerTime_callback);  //
asynchronous call

var textLen = WebUserControl1.create();

textLen.prototype = {
  initialize: function(ele) {
    this.ele = ele;
    this.display = document.getElementById(this.ele.id + "_display");
    addEvent(this.ele, "keyup", this.dosearch.bind(this));
  },
  dosearch: function() {
  AjaxSamples.WebUserControl1.GetLength(this.ele.value,
this.ondata.bind(this));
  },
  ondata: function(res) {
    this.display.innerHTML = res.value;
  }
};

function init() {
  var x = new textLen(document.getElementById("<%=ClientID%>"));
  // x.ele.focus();
}

addEvent(window, "load", init);

</script>


<input type="text" id="<%=ClientID%>"/>
<div>Length of the string: <span
id="<%=ClientID%>_display">0</span></div>



In my WebUsercontrol.ascx.cs i have

        private void Page_Load(object sender, System.EventArgs e)
                {
                        // Put user code to initialize the page here
                        
AjaxPro.Utility.RegisterTypeForAjax(typeof(WebUserControl1),
this.Parent.Page);
                }

                #region Web Form Designer generated code
                override protected void OnInit(EventArgs e)
                {
                        //
                        // CODEGEN: This call is required by the ASP.NET Web 
Form Designer.
                        //
                        InitializeComponent();
                        base.OnInit(e);
                }

                /// <summary>
                ///             Required method for Designer support - do not 
modify
                ///             the contents of this method with the code 
editor.
                /// </summary>
                private void InitializeComponent()
                {
                        this.Load += new System.EventHandler(this.Page_Load);
                }
                #endregion

                [AjaxPro.AjaxMethod]
                public int GetLength(string s)
                {
                        return s.Length;
                }


--~--~---------~--~----~------------~-------~--~----~
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/

Don't forget to read my blog at http://weblogs.asp.net/mschwarz/
-~----------~----~----~----~------~----~------~--~---

Reply via email to