Search Results

Search found 12 results on 1 pages for 'icallbackeventhandler'.

Page 1/1 | 1 

  • When implementing the ICallbackEventHandler in asp.net, in my c# function the RegularExpressionValid

    - by Mausimo
    Hello, As the question states, i have implemented my first ICallbackEventHandler. In my c# callback function i use: Page.Validate("ENewsLetter2"); if (Page.IsValid) { if (!RegularExpressionValidatorEmail.IsValid) { sInvalidMessage += "Invalid E-Mail address.\n"; } return sInvalidMessage; } everytime i check the RegularExpressionValidatorEmail, the value is = "". I do not know if this is since the iCallbackEventHandler is asynchronous, the validator has not talked to the server yet so the value will always show up blank? Is it impossible to do what i am trying to do by using a iCallbackEventHandler?

    Read the article

  • Dynamically add event to custom control (Confirm Message Box)

    - by Nyein Nyein Chan Chan
    I have created a custom cofirm message box control and I created an event like this- [Category("Action")] [Description("Raised when the user clicks the button(ok)")] public event EventHandler Submit; protected virtual void OnSubmit(EventArgs e) { if (Submit != null) Submit(this, e); } The Event OnSubmit occurs when user click the OK button on the Confrim Box. void IPostBackEventHandler.RaisePostBackEvent(string eventArgument) { OnSubmit(e); } Now I am adding this OnSubmit Event Dynamically like this- In aspx- <my:ConfirmMessageBox ID="cfmTest" runat="server" ></my:ConfirmMessageBox> <asp:Button ID="btnCallMsg" runat="server" onclick="btnCallMsg_Click" /> <asp:TextBox ID="txtResult" runat="server" ></asp:TextBox> In cs- protected void btnCallMsg_Click(object sender, EventArgs e) { cfmTest.Submit += cfmTest_Submit;//Dynamically Add Event cfmTest.ShowConfirm("Are you sure to Save Data?"); //Show Confirm Message using Custom Control Message Box } protected void cfmTest_Submit(object sender, EventArgs e) { txtResult.Text = "User Confirmed";//I set the text to "User Confrimed" but it's not displayed txtResult.Focus();//I focus the textbox but I got Error } The Error I got is- System.InvalidOperationException was unhandled by user code Message="SetFocus can only be called before and during PreRender." Source="System.Web" So, when I dynamically add and fire custom control's event, there is an error in Web Control. If I add event in aspx file like this, <my:ConfirmMessageBox ID="cfmTest" runat="server" OnSubmit="cfmTest_Submit"></my:ConfirmMessageBox> There is no error and work fine. Can anybody help me to add event dynamically to custom control? Thanks.

    Read the article

  • Wrapping ASP.NET Client Callbacks

    - by Ricardo Peres
    Client Callbacks are probably the less known (and I dare say, less loved) of all the AJAX options in ASP.NET, which also include the UpdatePanel, Page Methods and Web Services. The reason for that, I believe, is it’s relative complexity: Get a reference to a JavaScript function; Dynamically register function that calls the above reference; Have a JavaScript handler call the registered function. However, it has some the nice advantage of being self-contained, that is, doesn’t need additional files, such as web services, JavaScript libraries, etc, or static methods declared on a page, or any kind of attributes. So, here’s what I want to do: Have a DOM element which exposes a method that is executed server side, passing it a string and returning a string; Have a server-side event that handles the client-side call; Have two client-side user-supplied callback functions for handling the success and error results. I’m going to develop a custom control without user interface that does the registration of the client JavaScript method as well as a server-side event that can be hooked by some handler on a page. My markup will look like this: 1: <script type="text/javascript"> 1:  2:  3: function onCallbackSuccess(result, context) 4: { 5: } 6:  7: function onCallbackError(error, context) 8: { 9: } 10:  </script> 2: <my:CallbackControl runat="server" ID="callback" SendAllData="true" OnCallback="OnCallback"/> The control itself looks like this: 1: public class CallbackControl : Control, ICallbackEventHandler 2: { 3: #region Public constructor 4: public CallbackControl() 5: { 6: this.SendAllData = false; 7: this.Async = true; 8: } 9: #endregion 10:  11: #region Public properties and events 12: public event EventHandler<CallbackEventArgs> Callback; 13:  14: [DefaultValue(true)] 15: public Boolean Async 16: { 17: get; 18: set; 19: } 20:  21: [DefaultValue(false)] 22: public Boolean SendAllData 23: { 24: get; 25: set; 26: } 27:  28: #endregion 29:  30: #region Protected override methods 31:  32: protected override void Render(HtmlTextWriter writer) 33: { 34: writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID); 35: writer.RenderBeginTag(HtmlTextWriterTag.Span); 36:  37: base.Render(writer); 38:  39: writer.RenderEndTag(); 40: } 41:  42: protected override void OnInit(EventArgs e) 43: { 44: String reference = this.Page.ClientScript.GetCallbackEventReference(this, "arg", "onCallbackSuccess", "context", "onCallbackError", this.Async); 45: String script = String.Concat("\ndocument.getElementById('", this.ClientID, "').callback = function(arg, context, onCallbackSuccess, onCallbackError){", ((this.SendAllData == true) ? "__theFormPostCollection.length = 0; __theFormPostData = ''; WebForm_InitCallback(); " : String.Empty), reference, ";};\n"); 46:  47: this.Page.ClientScript.RegisterStartupScript(this.GetType(), String.Concat("callback", this.ClientID), script, true); 48:  49: base.OnInit(e); 50: } 51:  52: #endregion 53:  54: #region Protected virtual methods 55: protected virtual void OnCallback(CallbackEventArgs args) 56: { 57: EventHandler<CallbackEventArgs> handler = this.Callback; 58:  59: if (handler != null) 60: { 61: handler(this, args); 62: } 63: } 64:  65: #endregion 66:  67: #region ICallbackEventHandler Members 68:  69: String ICallbackEventHandler.GetCallbackResult() 70: { 71: CallbackEventArgs args = new CallbackEventArgs(this.Context.Items["Data"] as String); 72:  73: this.OnCallback(args); 74:  75: return (args.Result); 76: } 77:  78: void ICallbackEventHandler.RaiseCallbackEvent(String eventArgument) 79: { 80: this.Context.Items["Data"] = eventArgument; 81: } 82:  83: #endregion 84: } And the event argument class: 1: [Serializable] 2: public class CallbackEventArgs : EventArgs 3: { 4: public CallbackEventArgs(String argument) 5: { 6: this.Argument = argument; 7: this.Result = String.Empty; 8: } 9:  10: public String Argument 11: { 12: get; 13: private set; 14: } 15:  16: public String Result 17: { 18: get; 19: set; 20: } 21: } You will notice two properties on the CallbackControl: Async: indicates if the call should be made asynchronously or synchronously (the default); SendAllData: indicates if the callback call will include the view and control state of all of the controls on the page, so that, on the server side, they will have their properties set when the Callback event is fired. The CallbackEventArgs class exposes two properties: Argument: the read-only argument passed to the client-side function; Result: the result to return to the client-side callback function, set from the Callback event handler. An example of an handler for the Callback event would be: 1: protected void OnCallback(Object sender, CallbackEventArgs e) 2: { 3: e.Result = String.Join(String.Empty, e.Argument.Reverse()); 4: } Finally, in order to fire the Callback event from the client, you only need this: 1: <input type="text" id="input"/> 2: <input type="button" value="Get Result" onclick="document.getElementById('callback').callback(callback(document.getElementById('input').value, 'context', onCallbackSuccess, onCallbackError))"/> The syntax of the callback function is: arg: some string argument; context: some context that will be passed to the callback functions (success or failure); callbackSuccessFunction: some function that will be called when the callback succeeds; callbackFailureFunction: some function that will be called if the callback fails for some reason. Give it a try and see if it helps!

    Read the article

  • Ajax, Callback, postback and Sys.WebForms.PageRequestManager.getInstance().add_beginRequest

    - by user338262
    Hi, I have a user control which encapsulates a NumericUpDownExtender. This UserControl implements the interface ICallbackEventHandler, because I want that when a user changes the value of the textbox associated a custom event to be raised in the server. By the other hand each time an async postback is done I shoe a message of loading and disable the whole screen. This works perfect when something is changed in for example an UpdatePanel through this lines of code: Sys.WebForms.PageRequestManager.getInstance().add_beginRequest( function (sender, args) { var modalPopupBehavior = $find('programmaticSavingLoadingModalPopupBehavior'); modalPopupBehavior.show(); } ); The UserControl is placed inside a detailsview which is inside an UpdatePanel in an aspx. When the custom event is raised I want another textbox in the aspx to change its value. So far, When I click on the UpDownExtender, it goes correctly to the server and raises the custom event, and the new value of the textbox is assigned in the server. but it is not changed in the browser. I suspect that the problem is the callback, since I have the same architecture for a UserControl with an AutoCompleteExtender which implement IPostbackEventHandler and it works. Any clues how can I solve this here to make the UpDownNumericExtender user control to work like the AutComplete one? This is the code of the user control and the parent: using System; using System.Web.UI; using System.ComponentModel; using System.Text; namespace Corp.UserControls { [Themeable(true)] public partial class CustomNumericUpDown : CorpNumericUpDown, ICallbackEventHandler { protected void Page_PreRender(object sender, EventArgs e) { if (!Page.IsPostBack) { currentInstanceNumber = CorpAjaxControlToolkitUserControl.getNextInstanceNumber(); } registerControl(this.HFNumericUpDown.ClientID, currentInstanceNumber); string strCallServer = "NumericUpDownCallServer" + currentInstanceNumber.ToString(); // If this function is not written the callback to get the disponibilidadCliente doesn't work if (!Page.ClientScript.IsClientScriptBlockRegistered("ReceiveServerDataNumericUpDown")) { StringBuilder str = new StringBuilder(); str.Append("function ReceiveServerDataNumericUpDown(arg, context) {}").AppendLine(); Page.ClientScript.RegisterClientScriptBlock(typeof(CorpNumericUpDown), "ReceiveServerDataNumericUpDown", str.ToString(), true); } nudeNumericUpDownExtender.BehaviorID = "NumericUpDownEx" + currentInstanceNumber.ToString(); ClientScriptManager cm = Page.ClientScript; String cbReference = cm.GetCallbackEventReference(this, "arg", "ReceiveServerDataNumericUpDown", ""); String callbackScript = "function " + strCallServer + "(arg, context)" + Environment.NewLine + "{" + Environment.NewLine + cbReference + ";" + Environment.NewLine + "}" + Environment.NewLine; cm.RegisterClientScriptBlock(typeof(CustomNumericUpDown), strCallServer, callbackScript, true); base.Page_PreRender(sender,e); } [System.ComponentModel.Browsable(true)] [System.ComponentModel.Bindable(true)] public Int64 Value { get { return (string.IsNullOrEmpty(HFNumericUpDown.Value) ? Int64.Parse("1") : Int64.Parse(HFNumericUpDown.Value)); } set { HFNumericUpDown.Value = value.ToString(); //txtAutoCompleteCliente_AutoCompleteExtender.ContextKey = value.ToString(); // TODO: Change the text of the textbox } } [System.ComponentModel.Browsable(true)] [System.ComponentModel.Bindable(true)] [Description("The text of the numeric up down")] public string Text { get { return txtNumericUpDown.Text; } set { txtNumericUpDown.Text = value; } } public delegate void NumericUpDownChangedHandler(object sender, NumericUpDownChangedArgs e); public event NumericUpDownChangedHandler numericUpDownEvent; [System.ComponentModel.Browsable(true)] [System.ComponentModel.Bindable(true)] [System.ComponentModel.Description("Raised after the number has been increased or decreased")] protected virtual void OnNumericUpDownEvent(object sender, NumericUpDownChangedArgs e) { if (numericUpDownEvent != null) //check to see if anyone has attached to the event numericUpDownEvent(this, e); } #region ICallbackEventHandler Members public string GetCallbackResult() { return "";//throw new NotImplementedException(); } public void RaiseCallbackEvent(string eventArgument) { NumericUpDownChangedArgs nudca = new NumericUpDownChangedArgs(long.Parse(eventArgument)); OnNumericUpDownEvent(this, nudca); } #endregion } /// <summary> /// Class that adds the prestamoList to the event /// </summary> public class NumericUpDownChangedArgs : System.EventArgs { /// <summary> /// The current selected value. /// </summary> public long Value { get; private set; } public NumericUpDownChangedArgs(long value) { Value = value; } } } using System; using System.Collections.Generic; using System.Text; namespace Corp { /// <summary> /// Summary description for CorpAjaxControlToolkitUserControl /// </summary> public class CorpNumericUpDown : CorpAjaxControlToolkitUserControl { private Int16 _currentInstanceNumber; // This variable hold the instanceNumber assignated at first place. public short currentInstanceNumber { get { return _currentInstanceNumber; } set { _currentInstanceNumber = value; } } protected void Page_PreRender(object sender, EventArgs e) { const string strOnChange = "OnChange"; const string strCallServer = "NumericUpDownCallServer"; StringBuilder str = new StringBuilder(); foreach (KeyValuePair<String, Int16> control in controlsToRegister) { str.Append("function ").Append(strOnChange + control.Value).Append("(sender, eventArgs) ").AppendLine(); str.Append("{").AppendLine(); str.Append(" if (sender) {").AppendLine(); str.Append(" var hfield = document.getElementById('").Append(control.Key).Append("');").AppendLine(); str.Append(" if (hfield.value != eventArgs) {").AppendLine(); str.Append(" hfield.value = eventArgs;").AppendLine(); str.Append(" ").Append(strCallServer + control.Value).Append("(eventArgs, eventArgs);").AppendLine(); str.Append(" }").AppendLine(); str.Append(" }").AppendLine(); str.Append("}").AppendLine(); Page.ClientScript.RegisterClientScriptBlock(typeof(CorpNumericUpDown), Guid.NewGuid().ToString(), str.ToString(), true); } str = new StringBuilder(); foreach (KeyValuePair<String, Int16> control in controlsToRegister) { str.Append(" funcsPageLoad[funcsPageLoad.length] = function() { $find('NumericUpDownEx" + control.Value + "').add_currentChanged(").Append(strOnChange + control.Value).Append(");};").AppendLine(); str.Append(" funcsPageUnLoad[funcsPageUnLoad.length] = function() { $find('NumericUpDownEx" + control.Value + "').remove_currentChanged(").Append(strOnChange + control.Value).Append(");};").AppendLine(); } Page.ClientScript.RegisterClientScriptBlock(typeof(CorpNumericUpDown), Guid.NewGuid().ToString(), str.ToString(), true); } } } and to create the loading view I use this: //The beginRequest event is raised before the processing of an asynchronous postback starts and the postback is sent to the server. You can use this event to call custom script to set a request header or to start an animation that notifies the user that the postback is being processed. Sys.WebForms.PageRequestManager.getInstance().add_beginRequest( function (sender, args) { var modalPopupBehavior = $find('programmaticSavingLoadingModalPopupBehavior'); modalPopupBehavior.show(); } ); //The endRequest event is raised after an asynchronous postback is finished and control has been returned to the browser. You can use this event to provide a notification to users or to log errors. Sys.WebForms.PageRequestManager.getInstance().add_endRequest( function (sender, arg) { var modalPopupBehavior = $find('programmaticSavingLoadingModalPopupBehavior'); modalPopupBehavior.hide(); } ); Thanks in advance! Daniel.

    Read the article

  • Cannot set textbox value in Callback handler in asp.net

    - by user102533
    I am using ASP.NET Callbacks (that implements the ICallbackEventHandler) and in the handler, I try to set a value of the text box: txtName.text = "Test"; but this value is not set. Is this a limitation with callback? It appears I cannot do much in a callback handler other than sending back a string to the client side (ofcourse I can access the Session etc)

    Read the article

  • DevExpress AspxGridView clientside SelectionChanged problem when using paged ObjectDataSource

    - by Constantin Baciu
    The context is as follows: One DexExpress AspxGridView with a server-side paging/filtering/sorting mechanism (using ObjectDataSource). I've been having problems with the filter mechanism ( see this stack ). Now, the problem I'm having is this: the client-side events get mangled between DataSource events. :O . Let me explain what happens: if I change the page (or sort/filter for that matter), then, select one row from the grid, the client-side SelectionChanged event fires well. If I change the page (or sort/filter), the event doesn't fire anymore. Instead, on the server side, I get a "The method or operation is not implemented" exception with the following stack-trace: at DevExpress.Web.Data.WebDataProviderBase.GetListSouceRowValue(Int32 listSourceRowIndex, String fieldName) at DevExpress.Web.Data.WebDataProxy.GetListSourceRowValue(Int32 listSourceRowIndex, String fieldName) at DevExpress.Web.Data.WebDataProxy.GetKeyValueCore(Int32 index, GetKeyValueCallback getKeyValue) at DevExpress.Web.Data.WebDataSelectionBase.GetSelectedValues(String[] fieldNames, Int32 visibleStartIndex, Int32 visibleRowCountOnPage) at DevExpress.Web.Data.WebDataProxy.GetSelectedValues(String[] fieldNames) at DevExpress.Web.ASPxGridView.ASPxGridView.FBSelectFieldValues(String[] args) at DevExpress.Web.ASPxGridView.ASPxGridView.GetCallbackResultCore() at DevExpress.Web.ASPxGridView.ASPxGridView.GetCallbackResult() at DevExpress.Web.ASPxClasses.ASPxWebControl.System.Web.UI.ICallbackEventHandler.GetCallbackResult() Am I doing something wrong? Any help will be much appreciated.

    Read the article

  • DevExpress AspxGridView clientside SelectionChanged problem when using paged ObjectDataSource

    - by Constantin Baciu
    The context is as follows: One DexExpress AspxGridView with a server-side paging/filtering/sorting mechanism (using ObjectDataSource). I've been having problems with the filter mechanism ( see this stack ). Now, the problem I'm having is this: the client-side events get mangled between DataSource events. :O . Let me explain what happens: if I change the page (or sort/filter for that matter), then, select one row from the grid, the client-side SelectionChanged event fires well. If I change the page (or sort/filter), the event doesn't fire anymore. Instead, on the server side, I get a "The method or operation is not implemented" exception with the following stack-trace: at DevExpress.Web.Data.WebDataProviderBase.GetListSouceRowValue(Int32 listSourceRowIndex, String fieldName) at DevExpress.Web.Data.WebDataProxy.GetListSourceRowValue(Int32 listSourceRowIndex, String fieldName) at DevExpress.Web.Data.WebDataProxy.GetKeyValueCore(Int32 index, GetKeyValueCallback getKeyValue) at DevExpress.Web.Data.WebDataSelectionBase.GetSelectedValues(String[] fieldNames, Int32 visibleStartIndex, Int32 visibleRowCountOnPage) at DevExpress.Web.Data.WebDataProxy.GetSelectedValues(String[] fieldNames) at DevExpress.Web.ASPxGridView.ASPxGridView.FBSelectFieldValues(String[] args) at DevExpress.Web.ASPxGridView.ASPxGridView.GetCallbackResultCore() at DevExpress.Web.ASPxGridView.ASPxGridView.GetCallbackResult() at DevExpress.Web.ASPxClasses.ASPxWebControl.System.Web.UI.ICallbackEventHandler.GetCallbackResult() Am I doing something wrong? Any help will be much appreciated.

    Read the article

  • How to Resolve Jason issue

    - by Mohammad Nezhad
    I am working in a web scheduling application which uses DayPilot component I started by reading the documentation and use the calendar control. but whenever I do some thing which (fires an event on the Daypilot control) I face with following error An exception was thrown in the server-side event handler: System.InvalidCastException: Instance Of JasonData doesn't hold a double at DayPilot.Jason.JasonData.op_Explicit(JasonData data) at DayPilot.Web.Ui.Events.EventMoveEventArgs..ctor(JasonData parameters, string[] fields, JasonData data) at DayPilot.Web.Ui.DayPilotCalendar.ExecuteEventJASON(String ea) at DayPilot.Web.Ui.DayPilotCalendar.System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent(string ea) at System.Web.UI.Page.PrepareCallback(String callbackControlID) here is the completed code in the ASPX page <DayPilot:DayPilotCalendar ID="DayPilotCalendar1" runat="server" Direction="RTL" Days="7" DataStartField="eventstart" DataEndField="eventend" DataTextField="name" DataValueField="id" DataTagFields="State" EventMoveHandling="CallBack" OnEventMove="DayPilotCalendar1_EventMove" EventEditHandling="CallBack" OnEventEdit="DayPilotCalendar1_EventEdit" EventClickHandling="Edit" OnBeforeEventRender="DayPilotCalendar1_BeforeEventRender" EventResizeHandling="CallBack" OnEventResize="DayPilotCalendar1_EventResize" EventDoubleClickHandling="CallBack" OnEventDoubleClick="DayPilotCalendar1_EventDoubleClick" oncommand="DayPilotCalendar1_Command" and here is the complete codebehind protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) Initialization(); } private void dbUpdateEvent(string id, DateTime start, DateTime end) { // update for move using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["db"].ConnectionString)) { con.Open(); SqlCommand cmd = new SqlCommand("UPDATE [event] SET [eventstart] = @start, [eventend] = @end WHERE [id] = @id", con); cmd.Parameters.AddWithValue("id", id); cmd.Parameters.AddWithValue("start", start); cmd.Parameters.AddWithValue("end", end); cmd.ExecuteNonQuery(); } } private DataTable dbGetEvents(DateTime start, int days) { // get Data SqlDataAdapter da = new SqlDataAdapter("SELECT [id], [name], [eventstart], [eventend], [state], [other] FROM [event] WHERE NOT (([eventend] <= @start) OR ([eventstart] >= @end))", ConfigurationManager.ConnectionStrings["DayPilotTest"].ConnectionString); ; da.SelectCommand.Parameters.AddWithValue("start", start); da.SelectCommand.Parameters.AddWithValue("end", start.AddDays(days)); DataTable dt = new DataTable(); da.Fill(dt); return dt; } protected void DayPilotCalendar1_EventMove(object sender, DayPilot.Web.Ui.Events.EventMoveEventArgs e) { // Drag and Drop dbUpdateEvent(e.Value, e.NewStart, e.NewEnd); DayPilotCalendar1.DataSource = dbGetEvents(DayPilotCalendar1.StartDate, DayPilotCalendar1.Days); DayPilotCalendar1.DataBind(); DayPilotCalendar1.Update(); } private void Initialization() { // first bind DayPilotCalendar1.StartDate = DayPilot.Utils.Week.FirstDayOfWeek(new DateTime(2009, 1, 1)); DayPilotCalendar1.DataSource = dbGetEvents(DayPilotCalendar1.StartDate, DayPilotCalendar1.Days); DataBind(); } protected void DayPilotCalendar1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e) { // change the color based on state if (e.Tag["State"] == "Fixed") { e.DurationBarColor = "Brown"; } } protected void DayPilotCalendar1_EventResize(object sender, DayPilot.Web.Ui.Events.EventResizeEventArgs e) { dbUpdateEvent(e.Value, e.NewStart, e.NewEnd); DayPilotCalendar1.DataSource = dbGetEvents(DayPilotCalendar1.StartDate, DayPilotCalendar1.Days); DayPilotCalendar1.DataBind(); DayPilotCalendar1.Update(); } protected void DayPilotCalendar1_EventDoubleClick(object sender, EventClickEventArgs e) { dbInsertEvent(e.Text , e.Start, e.End, "New", "New Meeting"); DayPilotCalendar1.DataSource = dbGetEvents(DayPilotCalendar1.StartDate, DayPilotCalendar1.Days); DayPilotCalendar1.DataBind(); DayPilotCalendar1.Update(); } note that I remove unnecessary code behinds

    Read the article

  • ASP.NET Client to Server communication

    - by Nelson
    Can you help me make sense of all the different ways to communicate from browser to client in ASP.NET? I have made this a community wiki so feel free to edit my post to improve it. Specifically, I'm trying to understand in which scenario to use each one by listing how each works. I'm a little fuzzy on UpdatePanel vs CallBack (with ViewState): I know UpdatePanel always returns HTML while CallBack can return JSON. Any other major differences? ...and CallBack (without ViewState) vs WebMethod. CallBack goes through most of the Page lifecycle, WebMethod doesn't. Any other major differences? IHttpHandler Custom handler for anything (page, image, etc.) Only does what you tell it to do (light server processing) Page is an implementation of IHttpHandler If you don't need what Page provides, create a custom IHttpHandler If you are using Page but overriding Render() and not generating HTML, you probably can do it with a custom IHttpHandler (e.g. writing binary data such as images) By default can use the .axd or .ashx file extensions -- both are functionally similar .ashx doesn't have any built-in endpoints, so it's preferred by convention Regular PostBack (System.Web.UI.Page : IHttpHandler) Inherits Page Full PostBack, including ViewState and HTML control values (heavy traffic) Full Page lifecycle (heavy server processing) No JavaScript required Webpage flickers/scrolls since everything is reloaded in browser Returns full page HTML (heavy traffic) UpdatePanel (Control) Control inside Page Full PostBack, including ViewState and HTML control values (heavy traffic) Full Page lifecycle (heavy server processing) Controls outside the UpdatePanel do Render(NullTextWriter) Must use ScriptManager If no client-side JavaScript, it can fall back to regular PostBack with no JavaScript (?) No flicker/scroll since it's an async call, unless it falls back to regular postback. Can be used with master pages and user controls Has built-in support for progress bar Returns HTML for controls inside UpdatePanel (medium traffic) Client CallBack (Page, System.Web.UI.ICallbackEventHandler) Inherits Page Most of Page lifecycle (heavy server processing) Takes only data you specify (light traffic) and optionally ViewState (?) (medium traffic) Client must support JavaScript and use ScriptManager No flicker/scroll since it's an async call Can be used with master pages and user controls Returns only data you specify in format you specify (e.g. JSON, XML...) (?) (light traffic) WebMethod Class implements System.Web.Service.WebService HttpContext available through this.Context Takes only data you specify (light traffic) Server only runs the called method (light server processing) Client must support JavaScript No flicker/scroll since it's an async call Can be used with master pages and user controls Returns only data you specify, typically JSON (light traffic) Can create instance of server control to render HTML and sent back as string, but events, paging in GridView, etc. won't work PageMethods Essentially a WebMethod contained in the Page class, so most of WebMethod's bullet's apply Method must be public static, therefore no Page instance accessible HttpContext available through HttpContext.Current Accessed directly by URL Page.aspx/MethodName (e.g. with XMLHttpRequest directly or with library such as jQuery) Setting ScriptManager property EnablePageMethods="True" generates a JavaScript proxy for each WebMethod Cannot be used directly in user controls with master pages and user controls Any others?

    Read the article

  • User created Validator wont call Client side validation Javascript on 'complex' user control.

    Hi All, I have created a user control (from System.Web.UI.UserControl), and created my own validator for the user control (from System.Web.UI.WebControls.BaseValidator). Everything works ok until I try to get the user control to do client side validation. While trying to debug this issue I have set 'Control to Validate' to a text box instead of the custom user control, and the client side script works fine! It appears to me that it has an a issue with my composite user control I have created. Has anyone encountered this issue before? Has anyone else seen client side validation fail on custom user controls? Some extra info : The composite control is a drop down list and 'loader image', as it is a ajax enabled drop down list (using ICallbackEventHandler). I know that the client side javascript is being written to the page, and have placed an alert('random message') as the first line in the validator function that only appears if it is validating a text box (i.e. not when it is validating my custom control) Language : C# (ASP.NET 2.0) and jQuery 1.2.6 in aspx file : <rms:UserDDL ID="ddlUserTypes" runat="server" PreLoad="true" /> <rms:DDLValidator ID="userTypesVal" ControlToValidate="ddlUserTypes" ErrorMessage="You have not selected a UserType" runat="server" Text="You have not selected a UserType" Display="Dynamic" EnableClientScript="true" /> in validator code behind protected string ScriptBlock { get { string nl = System.Environment.NewLine; return "<script type=\"text/javascript\">" + nl + " function " + ScriptBlockFunctionName + "(ctrl)" + nl + " {" + nl + " alert('Random message'); " + nl + " var selVal = $('#' + ctrl.controltovalidate).val(); " + nl + " alert(selVal);" + nl + " if (selVal === '-1') return false; " + nl + " return false; " + nl + " }" + nl + "</script>"; } } protected override void OnPreRender(EventArgs e) { if (this.DetermineRenderUplevel() && this.EnableClientScript) { Page.ClientScript.RegisterExpandoAttribute(this.ClientID, "evaluationfunction", this.ScriptBlockFunctionName); Page.ClientScript.RegisterClientScriptBlock(GetType(), this.ScriptBlockKey, this.ScriptBlock); } base.OnPreRender(e); } I know my ControlPropertiesValid() and EvaluateIsValid() work ok. I appreciate any help on this issue. Noel.

    Read the article

1