I am using GoDiagram in a web user control. I have written a handler for the GoView’s ObjectSingleClicked event. When a node in the diagram is clicked, I am trying to call Server.Transfer to load a new page based on information gathered from the clicked node.
Maybe I need to do something with the GoView1 object before I redirect to a new page?
Any advice you can give would really be appreciated.
Here is my code:
Protected Sub GoView1_ObjectSingleClicked(ByVal sender As Object, ByVal e As Northwoods.GoWeb.GoObjectEventArgs) Handles GoView1.ObjectSingleClicked
Dim n As GoBasicNode
n = GoView1.Document.PickObject(e.DocPoint, True)
Try
System.Web.HttpContext.Current.Server.Transfer(mTargetURL & “?id=” & n.PartID)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
When the call to System.Web.HttpContext… runs, an error is returned that states “Thread was being aborted”. Here is the entire exception report from my immediate window (sorry for the large post, but I think the information may be useful.)
An exception of type ‘System.Threading.ThreadAbortException’ occurred in App_Web_orgchart.ascx.cdcab7d2.zo5-04hs.dll but was not handled in user code
GoView.RaisePostBackEvent: System.Threading.ThreadAbortException: Thread was being aborted.
at OrgChart.GoView1_ObjectSingleClicked(Object sender, GoObjectEventArgs e) in C:\WebDocs\MySite\OrgChart.ascx.vb:line 92
at Northwoods.GoWeb.GoView.OnObjectSingleClicked(GoObjectEventArgs evt)
at Northwoods.GoWeb.GoView.RaiseObjectSingleClicked(GoObject obj, GoInputEventArgs evt)
at Northwoods.GoWeb.GoView.DoSingleClick(GoInputEventArgs evt)
at Northwoods.GoWeb.GoTool.DoClick(GoInputEventArgs evt)
at Northwoods.GoWeb.GoToolSelecting.Start()
at Northwoods.GoWeb.GoView.set_Tool(IGoTool value)
at Northwoods.GoWeb.GoToolManager.DoMouseUp()
at Northwoods.GoWeb.GoView.DoMouseUp()
at Northwoods.GoWeb.GoView.RaisePostBackEvent(String evtargs)
GoWebImageHandler.ProcessRequest: System.Threading.ThreadAbortException: Thread was being aborted.
at Northwoods.GoWeb.GoView.RaisePostBackEvent(String evtargs)
at Northwoods.GoWeb.GoWebImageHandler.ProcessRequest(HttpContext context)
A first chance exception of type ‘System.Threading.ThreadAbortException’ occurred in mscorlib.dll
There’s a problem in your code: you don’t know for sure that the object picked at the DocPoint is actually a GoBasicNode.
Also, GoObjectEventArgs.GoObject will give you the object that was clicked, so you don't have to search for it by calling PickObject.
[code] Dim n as GoBasicNode = Nothing If (TypeOf e.GoObject.ParentNode Is GoBasicNode) Then n = CType(e.GoObject.ParentNode, GoBasicNode) If (Not n Is Nothing) Then ... End If[/code]
I implemented the code like you showed in your example. But, I still have the same problem.
Should I “destroy” the GoView object before I call Server.Transfer to go to another page?
The odd thing is that the being called appears to load with no error. Only after all the page’s code has run, and the code exits the Page_Load event of the target page does the error occur.
Transfer is documented to end the thread, so it is supposed to throw a ThreadAbortException.
I have always used Response.Redirect instead. Take a look at the code in GoWebIntro.doc.
As an alternative solution, you might consider having the browser do the opening of a different web page instead of having the server do it. This is also shown in GoWebIntro.doc -- look for the JavaScript call to window.open.
Thank you very much for the information. I was able to at least prove that the problem has nothing to do with GoDiagram. I placed a button in my user control and tried to use Server.Transfer and Response.Redirect in the button’s click event to do the same thing. But, I still get the same error.
Using Javascript to open a new page may be the best way to go. Can you suggest a means of knowing which node was clicked? I have extended the BasicNode class to hold some additional information that I will need to pass to the new page.
So I will need to build a URL for the Window.Open() call, like this:
You can look at how some of the sample web applications pass GoPartInfo information to the browser, and how you can then look at properties of the goInfo JavaScript variable.
I am sorry Walter but, I can’t find any example of using GoPartInfo in a client script. I see the examples of the GetPartInfo overrides but, I don’t see how to access it in Javascript. I have been stuck on this for several days now.
The goInfo JavaScript variable is initialized to point to a JavaScript object that has the same properties and information that the corresponding GoPartInfo did on the server, for the GoObject that was at the X,Y point where the click occurred.
You can use the goFindInfoAt JavaScript function to find the "GoPartInfo"-like object for other points in the view, but this is rarely done.
I think all of the custom JavaScript code in the web samples is pretty small and simple, so it is always included inline in the .ASPX files.
So search for "GoPartInfo" in the C#/VB code, and "goInfo" in the JavaScript/ASPX code.
Finally!..and on a Friday afternoon too…AND on MY BIRTHDAY!!
I have a clickable org chart!
Thanks for all your help. The relationship between GetPartInfo and the GoInfo object being referenced in your javascript example finally sunk into my thick skull.