SetFocus() not working in macros based on user controls
This may not be a bug, but I can't find an otherwise appropriate place to post:
I have created a user control that manifests the contents of a form, and I have placed it in an Umbraco page. Once published, the registration form behaves correctly, except for one thing: The SetFocus() calls seem to have no effect, so the cursor does not start in the first TextBox as intended. However, they do work if I place the user control on a simple, non-Umbraco aspx page.
Thank you for your quick response! The macro is on the template. Here's the code that is not working, excerpted from the user control's code-behind file:
Basically, NewWebAccountWizard is a multiview, and depending on which view is active after the user control's logic has executed, it sets the focus and default button right before it's rendered.
But when placed on an Umbraco page as a macro, the same user control omits this code.
I thought that the problem might be due to the user control being placed in an ASP Content control, so I created a simple master page with a single ContentPlaceHolder, and I placed my user control in the Content control of a child page. It worked there without a hitch.
My user control had periods in the filename, like this:
LibraryProject.UserControls.LoginForm.ascx
When I remove all but the last period...
LibraryProjectUserControlsLoginForm.ascx
...the expected JavaScript is generated on the page, and SetFocus() works as intended.
Now the question remains for Umbraco developers: Why do extra periods in a user control's filename throw off ASP.NET's built-in JavaScript when used as an Umbraco macro?
SetFocus() not working in macros based on user controls
This may not be a bug, but I can't find an otherwise appropriate place to post:
I have created a user control that manifests the contents of a form, and I have placed it in an Umbraco page. Once published, the registration form behaves correctly, except for one thing: The SetFocus() calls seem to have no effect, so the cursor does not start in the first TextBox as intended. However, they do work if I place the user control on a simple, non-Umbraco aspx page.
Any thoughts?
Thanks,
Bryan
Hi Bryan
Do you insert the macro directly on the template or through the content section in a rich text editor?
And could you perhaps post a snippet of the code in your file?
/Jan
Thank you for your quick response! The macro is on the template. Here's the code that is not working, excerpted from the user control's code-behind file:
Basically, NewWebAccountWizard is a multiview, and depending on which view is active after the user control's logic has executed, it sets the focus and default button right before it's rendered.
I still haven't been able to resolve this issue, but I've found some additional clues.
When I place the user control on a regular ASPX page, the focus gets set correctly, but in an Umbraco page it no longer works.
On a regular ASPX page, the following JavaScript reference is automatically generated:
Along with this, at the bottom of the form:
But when placed on an Umbraco page as a macro, the same user control omits this code.
I thought that the problem might be due to the user control being placed in an ASP Content control, so I created a simple master page with a single ContentPlaceHolder, and I placed my user control in the Content control of a child page. It worked there without a hitch.
Solved! After much hair pulling and nail biting.
My user control had periods in the filename, like this:
When I remove all but the last period...
...the expected JavaScript is generated on the page, and SetFocus() works as intended.
Now the question remains for Umbraco developers: Why do extra periods in a user control's filename throw off ASP.NET's built-in JavaScript when used as an Umbraco macro?
is working on a reply...