to fire a button click event from client script
Code:
__doPostBack('btn_id','');
I just added this to my Base.Page class
Code:
protected override void OnLoad(System.EventArgs e)
{
if(Request["__EVENTTARGET"] == "PostBackCommand" && Request["__EVENTARGUMENT"] != null && IsPostBack)
{
PostBackCommand(Request["__EVENTARGUMENT"]);
}
}
/// <summary>
/// Overide this member to add handling of Commands
/// raised from client script using __doPostBack(eventTarget, eventArgument).
/// </summary>
/// <param name="command">The command to execute.</param>
protected virtual void PostBackCommand(string command){}
you overide PostBackCommand and use a select case/switch statement to act on diffrent commands bassed on the command string.
javascript to run a command from client/cause post back and proccess any PostBack Commands.
Code:
__doPostBack('PostBackCommand', 'command_name');
So using this system you would use a normal none server button with
Code:
onclick="clientScriptFunction()"
in the client script you then do what you need to with the client and then to prefom you server operation you call
Code:
__doPostBack('PostBackCommand','ButtonClick');
I think this can be very usefull. What do you guys say?