Fred Posted May 9, 2007 Report Share Posted May 9, 2007 I'm using .Net RenderFormat. I added the new ToolBarItem associated with my custom Command. I set command.Script = "alert('Test');"; but the alert function never gets called. command.Script = "alert('Test');"; but the alert function never gets called. Thanks. Quote Link to comment Share on other sites More sharing options...
Frank Posted May 10, 2007 Report Share Posted May 10, 2007 The Script property takes the name of the JavaScript fuction to be executed, not an actual javascript fragment. For example: cmd.Script = "MyCommand"; will call: function MyCommand (commandId) { alert(commandId); } Notice the commandId parameter that will be passed to the function. Quote Link to comment Share on other sites More sharing options...
Fred Posted May 10, 2007 Author Report Share Posted May 10, 2007 It still doen't work if I switch to use the name of Javascript function. Here is what I have in my aspx.cs Command command = new Command(Convert.ToInt32(MyCustomCommandId)); Command command = new Command(Convert.ToInt32(MyCustomCommandId));command.Text = "Test"; command.Style = CommandStyles.ShowTextOnly; "Test";command.Style = CommandStyles.ShowTextOnly; CommandStyles.ShowTextOnly;command.Script = "Button1_onclick"; "Button1_onclick"; Chart1.Commands.Add(command); ToolBarItem tbi = new ToolBarItem(MyCustomCommandId); ToolBarItem tbi = new ToolBarItem(MyCustomCommandId);Chart1.ToolBar.Insert(0, tbi); Here is the javascript code on aspx page: function Button1_onclick(commandId) { alert(commandId); } the javascript function never gets called when i push the new button. Is there anything wrong with my code? Thanks! Fred Button1_onclick(commandId) { alert(commandId); } the javascript function never gets called when i push the new button. Is there anything wrong with my code? Thanks! Fred Quote Link to comment Share on other sites More sharing options...
Fred Posted May 10, 2007 Author Report Share Posted May 10, 2007 Sorry the Quick reply doen't handle copy&paste very well, here is the correct post: It still doen't work if I switch to use the name of Javascript function. Here is what I have in my aspx.cs Command command = new Command(Convert.ToInt32(MyCustomCommandId)); command.Text = "Test";command.Style = CommandStyles.ShowTextOnly;command.Script = "Button1_onclick"; Chart1.Commands.Add(command); ToolBarItem tbi = new ToolBarItem(MyCustomCommandId);Chart1.ToolBar.Insert(0, tbi); Here is the javascript code on aspx page: function Button1_onclick(commandId) { alert(commandId); } the javascript function never gets called when i push the new button. Is there anything wrong with my code? Thanks! Fred Quote Link to comment Share on other sites More sharing options...
Frank Posted May 11, 2007 Report Share Posted May 11, 2007 Are you generating an Image or a .NET Client control? The Script property is only for interactive images, if you are using the .NET Client Control you have to process the UserCommand event in your JavaScript instead. Note, in order to capture events from your .NET Client Control your .NET Security settings need to be set to Full Trust. Quote Link to comment Share on other sites More sharing options...
Fred Posted May 11, 2007 Author Report Share Posted May 11, 2007 I'm generating a .Net client control. So I have to catch UserCommand event in Javascript. Do you have some sample code that I can take as reference? Regarding to setting .NET Security to Full Trust, is it enough to follow the procedure to ChartFX.WebForms.dll and choose tp apply to all asseblies with the same public key and uncheck the "Include version" option as described in this article http://support.softwarefx.com/Article.aspx?KBID=6141001&Product=CfxNet62&Embed=1 ? Thanks. Fred Quote Link to comment Share on other sites More sharing options...
Frank Posted May 11, 2007 Report Share Posted May 11, 2007 Here is a sample JavaScript that captures the user command event and process it: <script language="JavaScript" for="Chart1" event="UserCommand(sender, args)"><!-- if (args.CommandId == 1) { alert("Custom Command 1"); }--></script> As for the Full Trust issue, yes, as long as you authorize the client control to run in the client machine, it doesn't matter how, it can be using the strong name, the site, the zone or the specific assembly. Note that the assembly version of the .NET Client control changes from service pack to service pack. Quote Link to comment Share on other sites More sharing options...
Fred Posted May 14, 2007 Author Report Share Posted May 14, 2007 Unfortunately I couldn't make it to work. The UserComand never fires on the client. What dll do I have to grant Full Trust on the client? Thanks. Fred Quote Link to comment Share on other sites More sharing options...
Frank Posted May 15, 2007 Report Share Posted May 15, 2007 The Chart FX .NET Client. I suggest that to try first, grant full permission to the entire zone, then once you get it working you can do it more granular as explained in the KB article. Note that I am talking about the security settings in the client computer, not the server. Quote Link to comment Share on other sites More sharing options...
Fred Posted May 16, 2007 Author Report Share Posted May 16, 2007 It still doen't work even if I granted Full Trust to eveny zone except untrusted zone on the client machine. Can you provide more details on how to make it work? Thanks. Fred Quote Link to comment Share on other sites More sharing options...
Frank Posted May 21, 2007 Report Share Posted May 21, 2007 Make sure UseClientLoader is set to false for your chart, the Client Loader does not expose the chart events. Quote Link to comment Share on other sites More sharing options...
Fred Posted May 22, 2007 Author Report Share Posted May 22, 2007 Yes I set it to false but it doesn't help. any other ideas? Can you describe the security setting process in details or provide an example that works? It will be highly appreciated. Thanks. Fred Quote Link to comment Share on other sites More sharing options...
Frank Posted May 23, 2007 Report Share Posted May 23, 2007 The attached project works for me if the appropriate security settings are used in the client. Quote Link to comment Share on other sites More sharing options...
Fred Posted June 4, 2007 Author Report Share Posted June 4, 2007 Thanks for the code, Frank. I finally made it to work. The reason it didn't work is that Asp.Net messed the ControlID around when you use a page inherited from a MasterPage. So once I switched to use <script language="JavaScript" for='<%=Chart1.UniqueID%>' event="UserCommand(sender, args)">rather than <script language="JavaScript" for="Chart1" event="UserCommand(sender, args)">Everything started working properly. Thank you again for all the help Frank! Fred Quote Link to comment Share on other sites More sharing options...
Frank Posted June 11, 2007 Report Share Posted June 11, 2007 Using Chart1.UniqueID is the right way to do it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.