Copied to clipboard

Flag this post as spam?

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


  • Thomas Dolberg 74 posts 95 karma points
    Jan 29, 2011 @ 09:16
    Thomas Dolberg
    0

    Cannot get simple usercontrol to work in backend

    Hi,

     

    I am struggling with getting a user control to work in the backend.

    For testing purposes, I have created a very simple user control, that updates a label with current datetime when a button is clicked. But when I click the button, nothing happens. I have inserted my usercontrol below:

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="usercontrols.WebUserControl1" %>
    
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    
    
    <div>
    
    
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click"></asp:Button>
    
    </div>
    
    </ContentTemplate>
    </asp:UpdatePanel>

     

    In my codebehind I have:

            protected void Button1_Click(object sender, EventArgs e)
            {
                Label1.Text = DateTime.Now.ToString();
            }

     

    In dashboard.config I have inserted

         <tab caption="MyTest">
                  <control addPanel="true">/usercontrols/WebUserControl1.ascx</control>
          </tab>

     

    Any help is appreciated.

     

    Thanks

    Thomas

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 29, 2011 @ 10:36
    Jan Skovgaard
    0

    Hi Thomas

    Could you try to hardcode a text, which is displayed instead of a date maybe? Don't know if it could be something with the date formatting.

    I'm thinking like setting Label1.Text ='test'; for instance.

    /Jan

  • Thomas Dolberg 74 posts 95 karma points
    Jan 29, 2011 @ 11:50
    Thomas Dolberg
    0

    Hi Jan

     

    I tried to hardcode the text, but it did not make any difference.

     

    Btw I am on Umbraco 4.6

     

    /Thomas

  • Eran Meir 401 posts 543 karma points
    Jan 29, 2011 @ 15:58
    Eran Meir
    0

    i don't think its umbraco related, i think its related to the updatepanel

  • Jesper Hauge 298 posts 487 karma points c-trib
    Jan 29, 2011 @ 16:03
    Jesper Hauge
    1

    Hi Thomas,

    How is your development setup? Are you building your control in an external web-app project, or are you writing your code, and building directly in the Umbraco website.

    Either way you need to make sure that the dll, that contains the compiled code for your user control is copied to the bin folder of the site at runtime.

    Regards
    Jesper Hauge

  • Thomas Dolberg 74 posts 95 karma points
    Jan 29, 2011 @ 21:56
    Thomas Dolberg
    0

    Hi

     

    The strange thing is that the exact same usercontrol works fine in the frontend-website. It is only in the backend, it does not work.

     

    The usercontrol is developed in the umbraco website.

     

    thanks

    Thomas

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 29, 2011 @ 21:57
    Jan Skovgaard
    0

    Hi Thomas

    Hmmm, maybe it's caching that is the problem then - what happens if you clear it?

    /Jan

  • Thomas Dolberg 74 posts 95 karma points
    Jan 29, 2011 @ 22:20
    Thomas Dolberg
    0

    Hi Jan

     

    I tried both clearing the browsercache and I also tried republishing the site, but it didn't solve the problem. I tried adding OnClientClick to see if it is only serverside-events which are not fired or if it is also clientside-events. The clientside-events are working but not the serverside-events. Do I need to register the serverside-events somehow besides the normal "OnClick" flow? Are there any casing conventions or something else, that I should be aware of?

    <asp:LinkButton ID="button1" runat="server" Text="Button" OnClick="button1_Click"
                    OnClientClick="alert('test');"></asp:LinkButton>

    Thanks

    Thomas

  • Andy Moore 7 posts 30 karma points
    Jan 30, 2011 @ 16:26
    Andy Moore
    1

    Thomas,

    I've been trying to figure out this same issue as well, and finally figured out what the problem was. If you're using a default installation of 4.6.1, one of the dashboard tabs in the Content area is Change Password. The changepassword usercontrol is using field validators in order to confirm that a user enters values in the textboxes. On your simple control, when it attempts to do a postback the runtime is first processing the field validators on the Change Password tab, and preventing a postback from occuring as the textboxes are not populated.

    If you comment out the Change Password tab in the dashboard.config your usercontrol will execute properly.

    Andy

  • Thomas Dolberg 74 posts 95 karma points
    Jan 31, 2011 @ 21:41
    Thomas Dolberg
    0

    Hi Andy

     

    thanks, it works. I don't think I would have figured it out myself :-)

     

    best regards

    Thomas

Please Sign in or register to post replies

Write your reply to:

Draft