|
Article relates to
|
RadAjax Classic
|
|
Created by
|
Ubong, Telerik
|
|
Last modified
|
March 13, 2008
|
|
Last modified by
|
Maria Ilieva, Telerik
|
PROBLEM
If you have an ImageButton on a page, when you click it the event arguments include the X,Y coordinates within the image that was clicked.
If you now wrap that ImageButton in an AjaxPanel, the event appears to lose the X,Y coordintates.
DESCRIPTION
Currently the X and Y coordinates of the image button are not supported when it is ajaxified with RadAjax.
SOLUTION
You can however use the following workaround to retrieve the needed information.
*This works for
IE6.0 and
Firefox 1.5 *
First, remove the button from the ajax panel, add an empty manager to the page and declare an Onclick handler for the image button:
| <radA:RadAjaxManager runat="server" ID="manager1" OnAjaxRequest="manager1_AjaxRequest"> |
| </radA:RadAjaxManager> |
| <script type="text/javascript"> |
| function mytest(e) |
| { |
| var manager = <%= manager1.ClientID %>; |
| manager.AjaxRequest(e.offsetX+","+e.offsetY); |
| } |
| </script> |
Once this is done, manually ajaxify the image button from the code behind:
| protected void Page_Load(object sender, EventArgs e) |
| { |
| //mytest is a javascript function declared in the .aspx file |
| ImageButton2.Attributes.Add("onclick", "mytest(window.event);return false;"); |
| } |
Finally you need to handle the custom ajax request:
| protected void manager1_AjaxRequest(object sender, Telerik.WebControls.AjaxRequestEventArgs e) |
| { |
| // e.Argument now contains the X,Y info... |
| string position_info = e.Argument; |
| } |
Please
Sign In
to rate this article.