Copied to clipboard

Flag this post as spam?

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


  • Neil Hodges 338 posts 987 karma points
    Feb 01, 2013 @ 17:08
    Neil Hodges
    0

    Button Click not working within Usercontrol

    Hi

    I have a user control rendered on the page, its using a macro.

    The usercontrol has a few lables and text boxs in it also using a multi view.

    There are 2 button at the bottom of the form and when clicked nothing happens, no error, no client side error. Client side validation works but no event click handler,

    I have set break points inside the user control and attatched the worker process, the page load gets hit by my break point but not the button click?!?

    Ive had a look at some articles on here about moving the form tag and setting the form tag runat server which im doing, but no matter where i put the form tag the buttons wont fire.

    On the Master page i have a few pop out forms, contact, newsletter, login, ive tried commenting them out thinking it may be the form tags within these causing a problem but still no click event.

    Any help on this would be greatly appreciated

    Kind Regards

    Neil.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 01, 2013 @ 17:11
    Jan Skovgaard
    0

    Hi Neil

    Could you perhaps share some code? Maybe that will make it a bit easier for people to suggest what could be wrong.

    Looking forward to hearing form you.

    /Jan

  • Neil Hodges 338 posts 987 karma points
    Feb 01, 2013 @ 17:16
    Neil Hodges
    0

    Yep no Problem, Here is my master page

    <asp:Content id="MasterLayoutcontent" ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">
      <title id="TitleTag" visible="false" runat="server"><%-- hack to turn the auto title off --%></title>
      <!-- META TAGS -->
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <meta name="AUTHOR" content="Tea Solutions Aps" />
      <umbraco:Macro Alias="MetaDescription" runat="server" />

      <!-- STYLESHEETS -->
     
      <link href='http://fonts.googleapis.com/css?family=Droid+Serif:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
      <link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
      <link rel="stylesheet" type="text/css" href="/css/webfonts.css" media="screen, print" />
      <link rel="stylesheet" type="text/css" href="/css/default.css" media="screen, print" />
      <link rel="stylesheet" type="text/css" href="/css/ecommerce.css" media="screen, print" />
      <link rel="stylesheet" type="text/css" href="/css/print.css" media="print" />

      <!-- JAVASCRIPT -->
      <script type="text/javascript">
          var _nodeId = <umbraco:Item field="pageID" runat="server" />;
          var _languageId = <umbraco:Item field="pageID" runat="server" xslt="teacommerce:GetUmbracoLanguageIdByNodeId({0})" />;
      </script>
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
      <script type="text/javascript" src="/scripts/TeaCommerce/teaCommerce.js"></script>
      <script type="text/javascript" src="/scripts/teaCommerce_Advanced.js"></script>
      <script type="text/javascript" src="/scripts/teaCommerce_Simple.js"></script>
      <script type="text/javascript" src="/scripts/default.js"></script>
      <script src="/scripts/jquery.carouFredSel-6.1.0.js"></script>
      <script src="/scripts/jquery.nivo.slider.pack.js"></script>
      <script src="/scripts/antiscroll.js"></script>
      <script src="/scripts/jquery-mousewheel.js"></script>
      <!-- PAGE SPECIFIC -->
       
      <asp:ContentPlaceHolder Id="CphHeader" runat="server"/>
     
      <script type="text/javascript">
     
          var _gaq = _gaq || [];
          _gaq.push(['_setAccount', 'ANALYTICS ID']);
          _gaq.push(['_trackPageview']);
          _gaq.push(['_trackPageLoadTime']);
       
          <umbraco:Macro Alias="GoogleEcommcereTracking" runat="server" />
     
          (function() {
              var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
              ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
              var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
          })();
     
      </script>
    </head>

    <body class="<umbraco:Item field="nodeTypeAlias" runat="server" />"
    <form runat="server">
        <umbraco:Macro ID="Macro1" imagesFrom="[$imageSliderFolder]"  showCaptions="0" Alias="ImageRotator" runat="server" />
        <div id="wrapper">
        <div id="top" class="noPrint">
          <a href="/" alt="<umbraco:Item field="#BackToFrontpage" runat="server" />" title="<umbraco:Item field="#BackToFrontpage" runat="server" />" id="logo">
            <img src="/css/gfx/logo.png" alt="<umbraco:Item field="#BackToFrontpage" runat="server" />" title="<umbraco:Item field="#BackToFrontpage" runat="server" />" />
          </a>
        <div class="TopBarMenu">
            <umbraco:Macro ID="Macro2" fromLevel="3" sort="ascending" navigationId="mainmenu" numberOfLevels="1" rootPage="" showOnlyCurrentPath="1" useSelfAsRoot="0" isSitemap="0" Alias="Navigation" imageProperty="" runat="server" />
        </div>
        </div>   
          <!-- Popout Panel -->
          <%--<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>--%>
          <div style="width:auto; height:auto;">
          <div class="LoginHolder">
                   <%--<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" ChildrenAsTriggers="True">
                    <ContentTemplate>
                        <umbraco:Macro ID="Macro4" Alias="RazorLogin" runat="server"></umbraco:Macro>
                  </ContentTemplate> 
                </asp:UpdatePanel>--%>
              <!-- Trigger -->
            <div class="trigger">
                  <img src="/images/LoginReg.jpg" alt="Login/Register" />
            </div>
          </div>
          <div class="KeepInTouchHolder">
                 <%-- <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Always" ChildrenAsTriggers="True">
                      <ContentTemplate>
                          <div class="KeepInTouchForm">
                          <h2 class="SubHeadings">Keep In Touch</h2>
                           <umbraco:Macro FormGuid="c7044d7a-bcd5-46a1-b7fd-cb572ff3b133" Alias="umbracoContour.RenderForm" runat="server"></umbraco:Macro>
                          </div>
                 </ContentTemplate>
                  </asp:UpdatePanel>--%>
              <!-- Trigger -->
            <div class="triggerKit">
                  <img src="/images/KeepInTouch_button.jpeg" alt="Keep In Touch" />
            </div>
          </div>
          <div class="RegisterHolder">
        <%--<asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="Always" ChildrenAsTriggers="True">
            <ContentTemplate>
                <div class="RegisterForm">
                    <h2 class="SubHeadings">Register Here</h2>
                    <umbraco:Macro ID="Macro5" FormGuid="5183e99f-7efa-4d0c-80c6-9967db632587" Alias="umbracoContour.RazorRenderForm" runat="server"></umbraco:Macro>
                </div>               
            </ContentTemplate>
        </asp:UpdatePanel>--%>
          </div>
          </div>
           
        <div class="body">
           <div id="content">
          <asp:ContentPlaceHolder Id="CphMain" runat="server" />
        </div>
        </div>

        <div class="MiddleSlider">
             
              <div class="image_carousel">
                  <div id="foo2">
                      <img src="../../css/gfx/MiddleSlider/image1-about.jpg" alt="basketball"  width="279" height="149"  />
                      <img src="../../css/gfx/MiddleSlider/image2-services.jpg" alt="basketball"  width="279" height="149"  />
                      <img src="../../css/gfx/MiddleSlider/image3-courses.jpg" alt="basketball"  width="279" height="149" />
                      <img src="../../css/gfx/MiddleSlider/image4-latestNews.jpg" alt="basketball"  width="279" height="149" />
                      <img src="../../css/gfx/MiddleSlider/image1-about.jpg" alt="basketball"  width="279" height="149"  />
                      <img src="../../css/gfx/MiddleSlider/image2-services.jpg" alt="basketball"  width="279" height="149"  />
                      <img src="../../css/gfx/MiddleSlider/image3-courses.jpg" alt="basketball"  width="279" height="149" />
                      <img src="../../css/gfx/MiddleSlider/image4-latestNews.jpg" alt="basketball"  width="279" height="149" />
                  </div>
                  <div class="clearfix"></div>
                  <a class="prev" id="foo2_prev" href="#"><span>prev</span></a>
                  <a class="next" id="foo2_next" href="#"><span>next</span></a>
                  <div class="pagination" id="foo2_pag"></div>
              </div>
             
        </div>
        <div class="BottomHolder">
           <div class="BottomFooter">
            <div class="SeeMoreHolder">
              <div class="SeeMore">
                  <img id="SeeContactForm" src="/images/footer_morebutton.png" alt="See More" />
              </div>
              <div class="SeeMore">
                <span id="SeerMoreText">CONTACT US</span>
            </div>
         </div>
            <div class="ContactForm">
                <div class="ContactHolder">
                <h2>Contact Us</h2>
                <div class="ContactUsForm">
                    <%--<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Always" ChildrenAsTriggers="True">
                        <ContentTemplate>--%>
                            <umbraco:Macro FormGuid="5f9a7c92-7aad-47ae-9a22-83851cd16e58" Alias="umbracoContour.RenderForm" runat="server"></umbraco:Macro>
                        <%--</ContentTemplate>
                    </asp:UpdatePanel>--%>
                   

                </div>
                <div class="ContactDetails">
                    <h5>Manchester Address:</h5>
                    <p>VCS Learning Solutions CIC, Piccadily House,<br />
                        49 Piccadilly, Manchester, M1 2AP<br />
                        Tel: 0161 212 1789
                    </p>
                    <br/>
                    <br/>
                    <h5>Burnley Address:</h5>
                    <p>VCS Learning Solutions CIC, Lodge House,<br />
                        Cow Lane, Burnley,Lancashire, BB11 1NN<br />
                        Tel: 01282 428 009
                    </p>
                </div>
                <div class="QucikLinks">
                    <h2>Quick Links</h2>
                </div>
                <div class="SocialMedia">
                    <h2>Social Media</h2>
                    <a href="https://www.facebook.com/VCSLearning" target="_blank" alt="Like us on Facebook">
                        <img src="/images/fb.jpg" />
                    </a>
                    <a href="https://twitter.com/vcslearning" target="_blank" alt="Follow us on Twitter">
                        <img src="/images/tw.jpg" />
                    </a>
                    <a href="#">
                        <img src="/images/linkedin.jpg" />
                    </a>
                </div>
                </div>
             </div>
            <div id="footer" class="noPrint">
            <umbraco:Macro ID="Macro3" Alias="Footer" runat="server" />       
            </div>
           </div>
           </div>
      </div>
    </form>
     
    </body>
    </html>
    </asp:Content>

     

     

    I have ommitted the javascript script tags for some sort of brevity

    Thanks, apreciate the help, my deadline is Monday and this is a big stumbling block

  • Neil Hodges 338 posts 987 karma points
    Feb 01, 2013 @ 18:17
    Neil Hodges
    0

    Just to add, im working with the TeaCommerce starter kit

  • pat 124 posts 346 karma points
    Feb 06, 2013 @ 13:51
    pat
    0

    did you build the project you have done usercontrols and copy the dll  to web site bin folder? also remember there should be only one form tag with runat="server" .

    so don't add any form tags in your usercontrol , add one form control in Master page template. 

    to test the functionality in your form you can add your form to a aspx page in your project and run at local host to test. or you can use ?umbdebugshowtrace=true in page url to see trace.

     

     

     

     

  • sagar 13 posts 33 karma points
    Mar 18, 2014 @ 13:07
    sagar
    0

    i am using umbraco 7 and i have created the one usercontrol and put one button in that

    page runs and control comes in the page load event but when i click a button nothing happens

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 18, 2014 @ 13:44
    Jan Skovgaard
    0

    Hi Sagar

    That's probably because you're in MVC mode, which is the default mode if Umbraco 7 if I remember correctly.

    If you're not able to convert to MVC there is an option to enable forms mode in the /config/umbracoSettings.config file. In the top of the file in the comments a reference to the documentation is mentioned. It might be handy if the place where you can change the mode is not visible, since some defaults are not visible in the config by default but can be added should one have changes to them.

    But before changing anything make sure you have a backup etc. if you're working on a serious site and is not just playing around with the new version.

    Cheers,
    Jan 

  • sagar 13 posts 33 karma points
    Mar 18, 2014 @ 13:52
    sagar
    0

    thnx for reply,

    i have some control in mvc partial view and some in .net then how can i manage that stuff and after change the rendermod still not works

    anyone help .....

  • Pinal 14 posts 34 karma points
    Mar 18, 2014 @ 14:32
    Pinal
    0

    Hello,

             I have also same problem.. i created one simple user control which have one button only and created macro for using that user control but when its render debugger going to page load event but not in the click event. i am using umbraco 7. Could any one please Help me to come out from this problem ?

     

     

    Thanks,

    Pinal

     

     

  • Neil Hodges 338 posts 987 karma points
    Mar 19, 2014 @ 10:12
    Neil Hodges
    0

    Hi

    This was some time ago, and i think the problem was using another for runat="server" tag inside the masterpages form runat="server" tag which was stopping the button postback.

    I fixed this by removing the masterpages form tag and only wrapping certain controls and other tmeplates in form tags where needed.

  • Neil Hodges 338 posts 987 karma points
    Mar 19, 2014 @ 10:18
    Neil Hodges
    0

    With your Umbraco 7 problem with your usercontrol not posting back you will need to create a Macro and point it to your usercontrol for it to work.

    Are your usercontrols built in a seperate project and compiled into DLL's? or are they in the 'usercontrol' folder in the root of your project?

    I ahve been wokring on moving a 4.0 build up to 7.0.3 and this had custom user controls, i dropped the DLL in the bin of the project and had the html usercontrols in the 'usercontrol' folder.

    I wrapped each usercontrol in a macro and then you can use on a 'masterpage' via adding the macro, im not sure if you can do the same on a 'View' or 'Partial View' as ive not tested that, but cant see why it wouldnt work.

    Kind Regards

    Neil.

Please Sign in or register to post replies

Write your reply to:

Draft