Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Andrew Munro 78 posts 161 karma points
    Apr 26, 2013 @ 19:30
    Andrew Munro
    0

    UserControl macro sub control events not firing. Request.Form is empty.

    Hi Guys - I'm trying to squash a bug that has been a big problem latley and I'm all out of ideas.

    We have a UserControl macro that forces a visitor to enter their information before being presented with a list of PDF files to download. The user control consists of 3 textboxes and a submit button. The sub controls are part of a package of controls called DevExpress dXperience.

    My problem is this: When I render this control on the page using umbraco macros, the page_load events work but the click events for my submit button never fire. I've tried debugging to see why the event doesn't fire and I also found that there is nothing in the Request.Form collection. It appears that while the button is sending the postback to the correct page, it's not actually sending any data.

    I've verified that I have a server form tag in my main masterpage and that I don't have any nested form tags. I've also tested this on a standalone page and it works properly when I do that. The problem only seems to arise when I render this through a macro. I've also disabled cache by page and cache personalized and the cache period is set to 0. 

    Any thoughts?

     

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 26, 2013 @ 23:41
    Tom Fulton
    0

    Is your submit button a LinkButton by chance?  I seem to recall issues with that, though normal buttons work fine.

    Other than that, nothing stands out.  Maybe try posting a stripped down version of the code you're using?  Also, which Umbraco version are you on?

  • Andrew Munro 78 posts 161 karma points
    Apr 27, 2013 @ 00:05
    Andrew Munro
    0

    Hey Tom - Thanks for the reply. It's actually called an ASPxButton which is basically a glorafied submit button with some visual styles and more server events. I even tried this with a barebones setup containing an asp textbox and an asp button. While debugging, the Form collection has no data which would explain why events aren't firing but what I'm not sure about is why the form is blank.

     

    Here is my code on my masterpage:

    <form id="Form1" runat="server"> 
    <%= RenderTabContent() %>
    </form>

    Here is my code that renders the macro and places it on the form (within a tab page)

       protected string RenderTabContent()
      {
                StringBuilder sbReturn = new StringBuilder();
                dynamic dNode = new DynamicNode(Node.getCurrentNodeId());
                Node nNode = Node.GetCurrent();
                int iCount = 0;
                foreach (dynamic dcTab in dNode.TabContainers.First().Children)
                {
                    sbReturn.AppendFormat("<ul id='product-tab-{0}' class='productTab {1}'>", iCount, ((iCount == 0) ? "" : "hide"));
                    sbReturn.AppendLine(umbraco.library.RenderMacroContent(dcTab.bodyContent.ToString(), dNode.Id));
                    sbReturn.AppendLine("</ul>");
                    iCount++;
                }
                return sbReturn.ToString();
        } 

    Now that I think of it it. I'm wondering if the RenderMacroContent method is the culprate here. Unfortunately this is a control that we have to let contributors add/remove as they wish so I cannot harcode the macro it into the template. However I will try hard coding it for the purposes of finding out if it's the RenderMacroContent method.

  • Andrew Munro 78 posts 161 karma points
    Apr 27, 2013 @ 00:39
    Andrew Munro
    0

    As I suspected the problem is with RenderMacroContent.  I tried hardcoding the same macro onto the page and everything works perfectly. The same macro that is rendered through umbraco.library.RenderMacroContent does not work. Any ideas on why?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 27, 2013 @ 00:43
    Tom Fulton
    0

    Yep - that's it.  RenderMacroContent doesn't support usercontrol postbacks.  This is a pretty old problem, not sure there's a real solution for it, other than rendering the RTE content from the template instead of passing through RenderMacroContent.  Maybe uComponents RenderTemplate might work?  Not sure there's going to be a good solution unfortunately.

    -Tom

Please Sign in or register to post replies

Write your reply to:

Draft