GoView_BackgroundDoubleClicked event does not fire

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:
<GoWeb:GoView ID="GoView1" runat="server" Height="308px" ImagePage="GoWebImage.axd"
NoPost="True" Width="309px" OnBackgroundDoubleClicked="GoView1_BackgroundDoubleClicked" />
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.

Walter,

Thanks for your help. I did everyting as you said. But it still did not fire off.
Then I changed sessionState mode in the web.config file from StateServer to InProc, the event works!
But our project must use StateServer as sessionState. What else shall I do to make the event work in StateServer mode?
Thanks.

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?

Thanks.

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() {}
protected CustomView(SerializationInfo info, StreamingContext context) : base(info, context) {}
protected override void OnBackgroundDoubleClicked(GoInputEventArgs e) {
GoBasicNode n = new GoBasicNode();
n.Text = e.DocPoint.ToString();
n.Location = e.DocPoint;
this.Document.Add(n);
}
}
}
Of course you can use the namespace and class name you prefer instead.
Then change your ASPX page to include the following directive:
<%@ Register Namespace="CustomApp" TagPrefix="local" %>
And change your GoView element to be a local:CustomView instead:
The attributes don't need to change -- just the element name.

Walter,

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" %>.
Any suggestion? Again, Thanks for your help.

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.

Walter,

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
Public Class SView
Inherits Northwoods.GoWeb.GoView
Public Sub New()
MyBase.New()
End Sub
End Class
Thank you.

But you haven’t implemented ISerializable, as I showed above.

Walter,

It works. Thanks for your time.