- assigned_to: nobody --> psiegers
Hi!
With the following extension you can specify the Event on which the CallBack is executed.
------------------------------------------------------
public enum CallBackOnType { onChange = 1 ,onKeyUp = 2 ,onKeyDown = 3, onBlur = 4}
public CallBackOnType CallBackOn
{
get
{
if (null == ViewState["CallBackOn"])
return CallBackOnType.onKeyUp;
else
return (CallBackOnType)ViewState["CallBackOn"];
}
set {ViewState["CallBackOn"] = value;}
}
-------------------------------------------------------
Then I changed the AddAttributesToRender Method:
-------------------------------------------------------
/// <summary>
/// Adds the <strong>onchange</strong> attribute to invoke a callback from the client, then renders
/// the attributes of the control to the output stream.
/// </summary>
///
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
if (AutoCallBack)
{
string sType = "";
if (this.CallBackOn == CallBackOnType.onChange)
{
sType = "onchange";
}
else if (this.CallBackOn == CallBackOnType.onKeyDown)
{
sType = "onkeydown";
}
else if (this.CallBackOn == CallBackOnType.onKeyUp)
{
sType = "onkeyup";
}
else if (this.CallBackOn == CallBackOnType.onBlur)
{
sType = "onblur";
}
Anthem.Manager.AddScriptAttribute(
this,
sType,
Anthem.Manager.GetCallbackEventReference(
this,
#if V2
this.CausesValidation,
this.ValidationGroup
#else
false,
string.Empty
#endif
)
);
}
base.AddAttributesToRender(writer);
}
------------------------------------------------------
Hope you find this as useful as I do.
Dennis