Hello,
I use web control pages extensively in my sites, and I just ran into a problem I've never had before.
I created a new page, the same way I always do using webpageparser, and distributed the page's .prg and .fxp to my live server (even though I only need the .fxp because I run precompiled pages on the server).
I ran the page and it rendered as expected, but when I clicked my submit button nothing happened. After checking my code many times, I went to the browser and viewed the source of my page. For some reason, all of the standard event handling and viewspace code wasn't in the source. Meaning, for example, the snippet in the below sample from one of my working pages was not in my new page:
Working page:
<form id="myform" name="Wwwebform" method="post">
<input type="hidden" id="__EVENTTARGET" name="__EVENTTARGET" value="" />
<input type="hidden" id="__EVENTARGUMENT" name="__EVENTARGUMENT" value="" />
<input type="hidden" id="__EVENTPARAMETER" name="__EVENTPARAMETER" value="" />
<input type="hidden" id="__VIEWSTATE" name="__VIEWSTATE" value="XnxncmRUcmFucz08fF9QU19DdXJyZW50UGFnZUluZGV4LXwtLTF8Pnxe" />
My new page has only the <form id...."> declaration, but none of the event handling code. I checked the code behind page and all of the controls were there and the rendering code looked correct.
I then picked an existing page that was working correctly, ran webpageparser on it again, and re-distributed the .fxp to the server and it ran as expected.
So I then created another brand-new page with only one control, a submit button, ran webpageparser and distributed it and it was missing the event handling code, just as my other brand-new page was.
I'm at a loss. Any help would be greatly appreciated! I'm running 6.20.
Thanks, Kirk
Is it Internet Explorer?
Internet Explorer has some weird issue if you submit a form when there is no interactive input control of some sort. You can work around this by adding an invisible input box on the form usually.
+++ Rick ---
Hi Rick,
No, not Explorer. I tried in Chrome and Firefox and had the same result. However, I solved the problem by just adding RegisterPostbackscriptcode() to the pages' Onload() method.
Also, I realized that these new pages that had the issue were the first ones I've created using WWWC vs 6; the others were all created using version 5.70. Maybe I haven't setup version 6 to automatically generate that code.
In any event, I figured it out.
Thanks Rick, Kirk
The postback code gets added only when a control that needs it is added to the form. Buttons generally don't need the postback code, because buttons post back their name and can be mapped to handlers directly, ynless you use a non-submitting button or JavaScript to submit your form.
+++ Rick ---