I have a Gannt chart with 2 items.
I need to allow the user to click a region on either of the items, and allow them to add a comment.
How do I determine on a click (server side) which item, and what time they clicked?
(I'll use this information to display the context of their selection that they are adding a comment to.)
I intend to store the comments in my application DB, and decorate each bar in the Gantt that has a comment with an outline...
Solved!
I moved both the script and the hidden field to the master page.
MasterPage.master:
BLOCKED SCRIPT
function ucHistory_ClientOnMouseClick(this_ref, row, column, value, row_label, column_label, evt_type, layer_id) { $get('<%= Gantt_Time_Entry_Index_Global.ClientID %>').value = layer_id.split(/-/)[1]; }
Hi David,
Thanks for your reply.
Unfortunately, my application is a bit too large to share at this point...
I'll summarize my application...
I've got a master page (which in retrospect has been more trouble than its worth)
One one of my pages, I have a UltraWebTree that allows the user to select one or more panels to display.
For each selection, I add a WebUserControl to an asp:Panel inside and asp:UpdatePanel
The WebUserControl that gets added has the GanttChart in it, and the hidden field, and the following BLOCKED SCRIPT
function ucHistory_ClientOnMouseClick(this_ref, row, column, value, row_label, column_label, evt_type, layer_id) { $get('<%= Gantt_Time_Entry_Index.ClientID %>').value = layer_id.split(/-/)[1]; }
This javascript works when there is only one WebUserControl added to the asp:Panel...
When there is more than one WebUserControl added to the panel, the javascript appears to be setting the value of a hidden field on a different instance of control than the one that got 'clicked'.
Since the code-behind is for a specific WebUserControl, I need the hiddenfield for that instance to be set -
I may try to dynamically add the hidden field, and insure that the ID is unique for each instance of the WebUserControl...
But much easier would be any way that I could alter the javascript to 'find' the right instance of the hiddenfield "Gantt_Time_Entry_Index" -
Thoughts?
(I realize this is hard with generalizations... but if you have any javascript kung-fu that would help, I'd appreciate it)
if it's on the main page, could you use document.getElementById as in the original suggestion?
i'm a few steps removed from understanding your application ... i don't really understand why the solution only worked for the last user control in the UpdatePanel, either.
i'm be happy to keep giving my best-guess answers, but this might be a case where providing a sample project or steps to reproduce would make troubleshooting a lot easier.
I'm having an issue with my implementation of the above solution.
I have a asp:UpdatePanel on my main page that gets user controls dynamically added to it.
The user controls contain the Gantt Chart, and the hidden field Gantt_Time_Entry_Index, that I am using to get the time index for the itrem clicked..
The solution above works only for the LAST user control added to the UpdatePanel. All other user controls result in no information in the hidden field.
Is there a way to use a hidden field on the main page to convey the time index?
(replace the $get('<%= Gantt_Time_Entry_Index.ClientID %>').value with javascript to find the hidden field on the main page...)
Thanks (may be a rookie javascript question... )
2.
Works!
I had to add a ScriptManagerProxy to my user control, and replace the
document.getElementById("Gantt_Time_Entry_Index").value
with
$get('<%= Gantt_Time_Entry_Index.ClientID %>').value
Thanks!