This is a migrated thread and some comments may be shown as answers.

Custom DropDowns with Binding to Server Event code??

3 Answers 87 Views
Editor
This is a migrated thread and some comments may be shown as answers.
E C Jowitt
Top achievements
Rank 1
E C Jowitt asked on 12 Jan 2009, 10:19 AM
Hi ,

using RadAjax RadEditor in  VS 2005.
When adding Custom DropDowns,..eg I created one to handle File Save As (external PDF files ..using some PDF 3rd party dll, and Send to (email) and FileOpen and SavetoDb.

The documentation provides for handling these events, but using OnClientCommandExecuted , which is client side.
?....How would i get these events to bind to and be fired on the server side.?
and
?  How would I hook up from this custom dropdown, to the Telerik  filemanager?


And please reply to nrogers@iafrica.com  (I logged in using the Company Account email, to get patches hotfixes etc)

Many Thanks Telerik
Neal



3 Answers, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 15 Jan 2009, 01:00 PM
Hi,

To achieve your scenario in the first point, you should obtain the dropdown value on the client, assign it to a hidden field and make a postback in order to obtain the hiddenfield value on the server. Here is a sample example how to implement my suggestion:

Default.aspx:

<telerik:RadEditor ID="RadEditor1" Skin="Telerik" OnClientCommandExecuting="OnClientCommandExecuting" runat="server"
   <Tools> 
       <telerik:EditorToolGroup>                 
            <telerik:EditorDropDown Name="CustomDropdown" Text="CustomDropdown" > 
                 <telerik:EditorDropDownItem  Name="English" value="English" /> 
                 <telerik:EditorDropDownItem  Name="Spanish" value="Spanish" /> 
                 <telerik:EditorDropDownItem  Name="German" value="German" /> 
                 <telerik:EditorDropDownItem  Name="French" value="French" /> 
                 <telerik:EditorDropDownItem  Name="Swedish" value="Swedish" /> 
            </telerik:EditorDropDown> 
        </telerik:EditorToolGroup> 
   </Tools>   
</telerik:RadEditor> 
<asp:HiddenField ID="HF1" runat="server" /> 
<asp:Button ID="Button1" runat="server" style="display:none;" /> 
<script type="text/javascript"
function OnClientCommandExecuting(editor, args) 
{                         
    var button = $get("<%=Button1.ClientID%>"); 
    var hiddenField = $get("<%=HF1.ClientID%>"); 
     
    if (args.get_name() == "CustomDropdown"
    { 
        hiddenField.value = args.get_value(); //get the dropdown item value and assign it to the hiddenfield element 
        button.click(); //make a postback and submit the hidden field value to the server 
        args.set_cancel(true);  
    } 
</script> 

Default.aspx.cs

    protected void Page_Load(object sender, EventArgs e) 
    { 
        string value = HF1.Value; 
        Response.Write(value); 
    } 

For your convenience I have attached my test files.

Could you please provide more information about the requested solution described in your second question:  ?  How would I hook up from this custom dropdown, to the Telerik  filemanager?  -
Can you open a support ticket and send us a sample working project that demonstrates your scenario?

Sincerely,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
E C Jowitt
Top achievements
Rank 1
answered on 19 Jan 2009, 07:27 AM
Hi, Thanks

Came up with similar soln.

In my edited Toolsfile, I added (at the Top)...(   I was aiming for a typical "File" menu structure)

<

EditorToolStrip Name="File" popupheight="118px">

 

<

tool name="Open" />

 

<

tool name="SaveToDb" />

 

<

tool name="SendToEmail" />

 

<

tool name="SaveAs" />

 

<

tool name="ShowPDF"/>

 

</

EditorToolStrip>

in the aspx, I set my icons/images
and
then I had the option of using

 

OnClientCommandExecuting

="OnClientCommandExecuting"> ...and some PostBack JS
or..

 

Telerik.Web.UI.Editor.CommandList[

"Open"] = function(commandName, editor, args)

 

{

__doPostBack(commandName,args);

};
I opted for the latter and interrogated the Postback with

 

 

string controlName = Request.Params.Get("__EVENTTARGET");

 

 

//Label1.Text = controlName;

 

 

 

 

 

if (controlName == "Open")

 

{

btnSaveTaskNotes();

}


The 2nd Question I had was easily resolved, by adding/moving  the existing 

 

<

tool name="DocumentManager" /> into the same dropdown toolbar, (provides then for js options on posting back) and following the Telerik examples.
Though I did write (download) a recursive folder/file browser C# code snippet...with someadditional code and rad windows to track and store Paths and System/User requirements. (easier from C# if your js is a bit lacking).

Many Thanks
Neal

 

0
Rumen
Telerik team
answered on 19 Jan 2009, 08:16 AM
Hi Neal,

Your solution looks interesting and our community can benefit from it if you post it as a code library. I will also give you 3000 Telerik points if you write a code library, attach a sample working project and share your code with the community.

Kind regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Editor
Asked by
E C Jowitt
Top achievements
Rank 1
Answers by
Rumen
Telerik team
E C Jowitt
Top achievements
Rank 1
Share this question
or