javascriptasp.netcomboboxtelerikradeditor

How to Execute a Javascript in ASP Button


I am using a JavaScript to add some content from a ComboBox to RadEditor using a button. It is working fine with HTML button. But, I need to Add another comobox and it should also do the same job, but it need to be hidden some times (Second Combobox is Not Visible All the time)..

<input type="button" onclick="pasteTextInEditor('<%=cmbOne.ClientID%>')" value="Add This Feild" class="button"/>
                                  <script type="text/javascript">
                                      function pasteTextInEditor(clientId) {

                                          var combo = $find(clientId);

                                          var editor = $find("<%=editorX.ClientID%>");
                                          editor.pasteHtml(combo.get_selectedItem().get_value());
                                      }
                                 </script>

Above Code is used to put contents from Combo to Rad Editor...


Solution

  • I am pretty sure, you can execute this function on client side with OnClientClick event provided from asp button.

    Example:

    OnClientClick="function (button,args){alertText('Alerted Text','Alerted Title');}