Copied to clipboard

Flag this post as spam?

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


  • mark 9 posts 63 karma points
    Apr 27, 2011 @ 14:01
    mark
    0

    button event not firing in User Control in v 4.7

    I have read all the other posts relating to this and nothing has help me to date.

    I have created a very basic User Control for my Umbraco v 4.7.0 installation.

    Page_Load Events fire fine but the button click event is not handled in the OnClick server side event. 

    Request.Form["__EVENTTARGET"] is returning null.

    Is this a bug in 4.7? I have developed simple control in 4.5.2 with no isues at all

    RegisterForCamp.ascx

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RegisterForCamp.ascx.cs" Inherits="umbraco_controls.usercontrols.RegisterForCamp" %>
    
    <form id="RegisterForCampForm" runat="server">
        <asp:Literal ID="litMessage" runat="server" />
        <asp:Button ID="btnRegister" runat="server" Text="Register" onclick="btnRegister_Click" />
    </form>

    RegisterForCamp.ascx.cs

    namespace umbraco_controls.usercontrols
    {
        public partial class RegisterForCamp : System.Web.UI.UserControl
        {
    
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    litMessage.Text = "Not a postback - works";
                }
                else
                {
                    litMessage.Text = "Is a postback - works";
                }
            }
    
            protected void btnRegister_Click(object sender, EventArgs e)
            {
                litMessage.Text = "Button click - fails";
            }
        }
    }
    
    

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 27, 2011 @ 14:07
    Tom Fulton
    0

    Hi Mark,

    In your template, are you wrapping the macro in a <form runat="server"> tag?  If you're not you need to do so for it to work properly.

    If not, is this on a dashboard or a page?

    -Tom

  • mark 9 posts 63 karma points
    Apr 27, 2011 @ 14:13
    mark
    0

    Thanks Tom this control is on a page.

    I am currently specifying my form tag in the user control.

    When i add it to the template as well i get an error: A page can have only one server-side Form tag.

    When i then delete the form tag from my user control i get the same issue as before.

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 27, 2011 @ 15:04
    Tom Fulton
    0

    Oops, didnt' see the form in your UC.  Strange though, seems to be working from here.  Perhaps something in your template is conflicting?  Maybe try it on a new/blank template?

    -Tom

  • mark 9 posts 63 karma points
    Apr 27, 2011 @ 15:58
    mark
    0

    Thanks Tom

    As soon as i did that it worked. The theme that i had implemented was running some javascript that replaced all submit elements with button elements.... because that's a good idea.

    I guess you roll the dice sometimes when you use something that you didn't develop.

Please Sign in or register to post replies

Write your reply to:

Draft