Thanks!
vithiya
6 Answers, 1 is accepted
You can try the following code using which a ContextMenu will pop up on rightclicking the RadTextBox.
aspx:
<telerik:RadTextBox ID="RadTextBox1" runat="server" onmousedown="showMenu(event);"> |
</telerik:RadTextBox > |
js:
<script type="text/javascript" > |
function showMenu(e) |
{ |
alert(event.which); |
if(event.button==2) |
{ |
var contextMenu = $find("<%= RadContextMenu1.ClientID %>"); |
if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) |
{ |
contextMenu.show(e); |
} |
$telerik.cancelRawEvent(e); |
} |
return false; |
} |
</script > |
Thanks
Princy.
Thanks!
vithiya
You can disable the browser context menu for an element in your DOM with the following JavaScript:
<telerik:RadTextBox ID="RadTextBox1" runat="server" oncontextmenu="return false;" onmousedown="return showMenu(event);">
</telerik:RadTextBox >
Kind regards,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thanks Princy. But still no luck. I keep getting the IE right click menu no matter what. Here is what I have in my code. I do have this textbox wraped in an Ajax Panel. Does that cause any issues?
<
telerik:RadTextBox ID="txtMessage" Runat="server" Height="90px"
TextMode="MultiLine" Width="400px" AutoPostBack="True"
oncontextmenu="return false;" onmousedown="return ShowMenu(event);">
</telerik:RadTextBox>
function
ShowMenu(e, control)
{
if(e.button==2)
{
storeCaretPosition = document.selection.createRange();
controlcontext = control;
var contextMenu = $find("<%= mnuInsertKeyword.ClientID %>");
contextMenu.show(e);
$telerik.cancelRawEvent(e);
}
return false;
}
Thank you!
vithiya
Attached, please find a small and running project showing the needed approach.
Kind regards,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
<
telerik:RadTextBox ID="txtMessage" Runat="server" Height="90px"
TextMode="MultiLine" Width="400px" AutoPostBack="True"
oncontextmenu="return ShowMenu(this);" >
</telerik:RadTextBox>
function
ShowMenu(control)
{
storeCaretPosition = document.selection.createRange();
controlcontext = control;
var contextMenu = $find("<%= mnuInsertKeyword.ClientID %>");
contextMenu.show(event);
return false;
}
Thank you!
Vithiya