NetTalk Central

Author Topic: NT7 - NetWebForm - InitForm Firing Twice  (Read 3195 times)

David

  • Full Member
  • ***
  • Posts: 127
    • View Profile
NT7 - NetWebForm - InitForm Firing Twice
« on: December 17, 2012, 12:22:54 PM »
C8/NT7.00

I have a NetWebForm with a Form Source of memory, that I use to manage app settings.  In the InitForm embed, I load my app settings into the Form variables.  I have a debug statement so I can see that the variables were loaded.  The debug statement fires 2 times every time I go to the webpage.  Is this expected behavior?

David

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: NT7 - NetWebForm - InitForm Firing Twice
« Reply #1 on: December 17, 2012, 04:23:27 PM »
I have the same problem, At least, it looks to me like it is the same.

I did not study NetTalk 6 behavior cause it works with popup window to show photo of product without hick up but NetTalk 7 send me GPF and does not show picture. After that every call of this popup window ends with GPF. Rest of application works well.

I played with debugger and found that this popup form is called at least once before I expect and it ends up silently. Second time call is from webhandler procedure when user ask for picture and it GPF on the very beginning of procedure with error 'Index Out of Range', but I does not see any index at all. So, I believe that error comes from other unknown reason.

NetTalk 6 still works well.

Best regards,

Djordje Radovanovic

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NT7 - NetWebForm - InitForm Firing Twice
« Reply #2 on: December 17, 2012, 11:07:18 PM »
Hi David,

>> Is this expected behavior?

Yes. Although sometimes it's called twice, sometimes once, it depends a bit on circumstances. A good way to see this in more detail is to go to the General tab of the form settings, right at the bottom is a setting to "Send stage to Debugview". This can be enlightening because it should how many times the Form "procedure" is called, and for what reason. A typical form can be called 6 or more times _just_ on startup. Of course it's doing different things each time - but the "collection of code called a form" is really a bunch of code snippets called from various places in the server.

Because of the paths various bits of code can take, the InitForm routine can be called twice.You'll notice however that it sets a Value
p_web.SetValue('MailboxesFormControl_form:inited_',1)
which you can test to see if you've been here before _on this thread_.

You may want to move your code to the PreUpdate routine which is called once.

Cheers
Bruce

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NT7 - NetWebForm - InitForm Firing Twice
« Reply #3 on: December 17, 2012, 11:09:06 PM »
Djordie,

I would need to see an example to be specific, but it sounds like maybe you have some code in the wrong place. Bear in mind that the form (in popup mode) is called at least once (with "Popup stage") long before the user even thinks of opening it.

cheers
Bruce