AJAX Page - Server to client methods

ShowAlert

This method shows an alert window with the specified message on client side.
For example, you can use the next lines:

    ShowAlert("This alert was sent by server"); 	
		
See also live ShowAlert Example.

SetValue

Set the value of an html element with specified id.
For example, you can use the next lines:
		
    // input elements (textboxes)
    SetValue("textElement", "someCustomValue"); 
	
    // dropdown elements (comboboxes)
    SetValue("selectElement", "3");
	
    // textareas
    SetValue("textareaElement", "some custom text");
		
See also live SetValue Example.

OpenWindow

Open a new window at client.
For example, you can use the next lines:

    OpenWindow("SomePage.aspx",);
    OpenWindow("SomePage.aspx", "_blank",);
    OpenWindow("SomePage.aspx", "_blank", "width=400, height=250");
    OpenWindow("SomePage.aspx", "_blank", "width=400, height=250", true);
		
See also live OpenWindow Example.

ShowConfirmationDialog

Shows a confirm dialog box with a specified message.
If the answer is Yes, server function is executed with the specified list of parameters.
For example, you can use the next lines:

    // These are the parameters that can be sent to the result function along with the response.
    Hashtable ht = new Hashtable();
    ht.Add("param1", 1);
    ht.Add("param2", "a");
		
    // Call the ShowConfirmationDialog function with the message, the function to call
    // after the user answers, and the extra parameters the function should have.
    ShowConfirmationDialog("Are you sure?", "Confirm", ht);
	
    public string Confirm (bool response, int param1, string param2)
    {
        // response is true or false depending on user choice
        // the rest of the params is what we saved as the last
        // parameter of ShowConfirmationDialog
        if (response)
        {
            // user chose OK
            //
            // do some execution
            //
            return "You clicked Ok";
        }
        else 
        {
            // user chose Cancel
            //
            // do some execution
            //
            return "You clicked Cancel";
        }
    }
		
See also live ShowConfirmationDialog Example.

CreateTimer, CancelTimer - client functions

Creates a timer, with an ID, that will trigger a client function on a time interval.
For example, you can use the next lines:

Server Side:

    // create a timer
    CreateTimer("timerID", "myClientFunction", 2000); 
	
    // cancel a timer
    CancelTimer("timerID");
		


See also live CreateTimer/CancelTimer Example.



CreateTimer, CancelTimer - server function

Creates a timer, with an ID, that will trigger a server function on a time interval.
For example, you can use the next lines:

Server Side:
		
    // create a timer
    CreateTimer("timerID", "myServerFunction", "myClientFunction", 2000);
	
    // function that will be called at every interval
    // and which can return something that myClientFunction can process
    public string myServerMethod()
    {
        return "some result";
    }
		

Client Side:
		
    // function that will be called with the result of serverFunctionToCall
    function myClientFunction(result, ex)
    {
        // if there was no error
        if (ex == null)
        {
            // process response here
            alert("Data received from the server on a time interval: " + result);
        }
    }
		
		


See also live CreateTimer/CancelTimer Example.