I have a GoView object. I set NoPost to true. Then some how the event handler GoView1_BackgroundDoubleClicked does not fire off. I tried the sample code DetaSetDemo and that does fire off. So what I missed here? In my case, If I set NoPost to false, the whole page refreshes and the event fires. But the blink defeats the whole purpose. Any suggestion? Thanks.
To test this, I created a new web site, dropped a GoView into the Default.aspx page and resized it, set GoView.NoPost to true, set GoView.ImagePage to “GoWebImage.axd” and added the following lines to the web.config file:
Then I switched the Properties grid to show events, double clicked the GoView.BackgroundDoubleClicked event, and defined the following handler:
protected void GoView1_BackgroundDoubleClicked(object sender, GoInputEventArgs e) { GoBasicNode n = new GoBasicNode(); n.Text = e.DocPoint.ToString(); n.Location = e.DocPoint; GoView1.Document.Add(n); }
I also added a "using Northwoods.GoWeb;" statement, of course.
And this runs just as I think you would expect.
Just for confirmation, here's the GoView element in Default.aspx:
Now, for a real application, I would also want to define a GoView.SessionStarted event handler to do initialization and handling session timeouts. And there's other GoView initialization and other application-specific work to be done. But at least the minimal application defining a GoView.BackgroundDoubleClicked event handler works as any Web Forms programmer using Visual Studio would expect.
Ah, that’s because the event handler isn’t being serialized/deserialized.
One way to get around this is to override GoView.OnNoPostLoad to make sure the event handler is established. This is discussed in GoWebIntro.doc as well as the documentation for that method.
Alternatively you can just override GoView.OnBackgroundDoubleClicked, and not bother with a separate event handler at all.
Can you give me some sample code on how to override GoView.OnNoPostLoad ? I mean do I have to write a separate extented class of GoView and put public override void OnNoPostLoad() inside the extended class?
OK. Basically this is just an exercise in how to define your own control, since there really isn’t anything that is specific to GoDiagram here, except that the GoView-inheriting class needs to be serializable by implementing ISerializable.
I'll override OnBackgroundDoubleClicked instead of adding an event handler in an override of OnNoPostLoad. Put the following code in a file in your App_Code subdirectory:
namespace CustomApp { [Serializable] public class CustomView : GoView, ISerializable { public CustomView() {}
Thanks for your reply. My project is a web application, not a web site app. So I do not have App_code folder.
I put my .vb file in the web root along with other files. When I call my test page, it bombed. It complains about <%@ Register Namespace="CustomApp" TagPrefix="local" %>. It says "Unknown server tag 'goweb1:SView'". My code is <%@ Register TagPrefix="goweb1" namespace="iq.gowebSView" %>.
First, I assume you got the class and namespace names correct for your app.
Second, your Register directive might need to specify the Assembly attribute with your kind of project as well as the Namespace and TagPrefix attributes.
By your help, I solved the unknown tag issue by specifying assembly. But still the extended class of GoView can only be loaded if the sessionState is InProc. If I set the sessionState to StateServer, I got the error: ? missing page: GoWebImage.axd. The image is not loaded.
It seems like the StateServer sessionState caused a ot of troubles.
My testing extended class is doing nothing. Here is my code in vb