Copied to clipboard

Flag this post as spam?

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


  • Axel 68 posts 96 karma points
    May 09, 2014 @ 21:56
    Axel
    0

    Custom Usercontrol on Contentpage Button Click Event not fired..

    Hi, i have create within umbraco (open umbraco 7.x as website with visual studio 2013)

    a simple user control.on the masterpage (master template) i have the form tag.

    i put now the usercontrol as macro on a contentpage. when i preview the page it runs into my breakpoint in the page_load event. but when click the button, it enters the page_load event but not the button_click event.

    i have it also tryed with OnClick="button_Click" but with no success.

    what could be wrong?

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 09, 2014 @ 22:58
    Jan Skovgaard
    0

    Hi Axel

    Is webforms enabled? Or is it running MVC?

    If webforms are already enabled could you then share your code since it will make it a bit easier to help you out?

    /Jan

  • Axel 68 posts 96 karma points
    May 10, 2014 @ 10:12
    Axel
    0

    Hi Jan, yes iam running on webforms.
    from which part did you want to see code?
    best regards axel

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 10, 2014 @ 10:42
    Jan Skovgaard
    0

    Hi Axel

    Ok, just try showing it all in here.

    Cheers, Jan

  • Axel 68 posts 96 karma points
    May 10, 2014 @ 21:35
    Axel
    0

    Hi Jan, here its my code
    Page Content
    <div class="umb-macro-holder mceNonEditable"><!-- <?UMBRACO_MACRO macroAlias="Intranet_Login" />

    Master Template
    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
    <asp:content contentplaceholderid="ContentPlaceHolderDefault" runat="server">

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"[]>
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head id="head" runat="server">
       
     
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <title><asp:placeholder runat="server"><umbraco:item runat="server" field="pageName"></umbraco:item> - <umbraco:item runat="server" field="siteName" recursive="true"></umbraco:item></asp:placeholder></title>
      <link rel="stylesheet" type="text/css" href="/css/Designit_Green.css">
      <umbraco:macro alias="BlogRssFeedLink" runat="server"></umbraco:macro>
      <asp:contentplaceholder id="cp_head" runat="server"></asp:contentplaceholder>
    </head>
      <body>   
        <div id="main">
        
          <asp:contentplaceholder id="cp_top" runat="server">
            <div id="top">
               
              <h1 id="siteName"><a href="/"><umbraco:item runat="server" field="siteName" recursive="true"></umbraco:item></a></h1>
              <umbraco:macro id="Macro1" alias="umbTopNavigation" runat="server"></umbraco:macro>
              <h2 id="siteDescription"><span><umbraco:item runat="server" field="siteDescription" recursive="true"></umbraco:item></span></h2>
            </div>
          </asp:contentplaceholder>
               
          <div id="body" class="clearfix">
             
              <form id="RunwayMasterForm" runat="server">
                 
                             <asp:contentplaceholder id="cp_content" runat="server"></asp:contentplaceholder>
              </form>
          </div> <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
    <asp:content contentplaceholderid="ContentPlaceHolderDefault" runat="server">

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"[]>
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head id="head" runat="server">
       
     
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <title><asp:placeholder runat="server"><umbraco:item runat="server" field="pageName"></umbraco:item> - <umbraco:item runat="server" field="siteName" recursive="true"></umbraco:item></asp:placeholder></title>
      <link rel="stylesheet" type="text/css" href="/css/Designit_Green.css">
      <umbraco:macro alias="BlogRssFeedLink" runat="server"></umbraco:macro>
      <asp:contentplaceholder id="cp_head" runat="server"></asp:contentplaceholder>
    </head>
      <body>   
        <div id="main">
        
          <asp:contentplaceholder id="cp_top" runat="server">
            <div id="top">
               
              <h1 id="siteName"><a href="/"><umbraco:item runat="server" field="siteName" recursive="true"></umbraco:item></a></h1>
              <umbraco:macro id="Macro1" alias="umbTopNavigation" runat="server"></umbraco:macro>
              <h2 id="siteDescription"><span><umbraco:item runat="server" field="siteDescription" recursive="true"></umbraco:item></span></h2>
            </div>
          </asp:contentplaceholder>
               
          <div id="body" class="clearfix">
             
              <form id="RunwayMasterForm" runat="server">
                 
                             <asp:contentplaceholder id="cp_content" runat="server"></asp:contentplaceholder>
              </form>
          </div>
          </div>
          <asp:contentplaceholder id="cp_footer" runat="server">
            <div id="footer-wrapper">
            <div id="footer">
                <p id="footer_text" class="address">testfooter</p>
                <umbraco:macro id="Macro2" alias="umbTopNavigation" runat="server"></umbraco:macro>
                <a class="credits" href="http://designit.com">Skin by Designit</a>
            </div>
            </div>
          </asp:contentplaceholder>
      </body>
    </html>
    <script type="text/C#" runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        umbraco.library.AddJquery();
        umbraco.library.RegisterJavaScriptFile("jquery.placeholder.js", "/scripts/Designit_Green/jquery.placeholder.js");
        umbraco.library.RegisterJavaScriptFile("Designit_Green.js", "/scripts/Designit_Green/Designit_Green.js");
    }
    </script>
    </asp:content>
          </div>
          <asp:contentplaceholder id="cp_footer" runat="server">
            <div id="footer-wrapper">
            <div id="footer">
                <p id="footer_text" class="address">testfooter</p>
                <umbraco:macro id="Macro2" alias="umbTopNavigation" runat="server"></umbraco:macro>
                <a class="credits" href="http://designit.com">Skin by Designit</a>
            </div>
            </div>
          </asp:contentplaceholder>
      </body>
    </html>
    <script type="text/C#" runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        umbraco.library.AddJquery();
        umbraco.library.RegisterJavaScriptFile("jquery.placeholder.js", "/scripts/Designit_Green/jquery.placeholder.js");
        umbraco.library.RegisterJavaScriptFile("Designit_Green.js", "/scripts/Designit_Green/Designit_Green.js");
    }
    </script>
    </asp:content>

     

     

    Textpage Template

    <%@ Master Language="C#" MasterPageFile="~/masterpages/umbMaster.master" AutoEventWireup="true" %>
    <asp:Content ContentPlaceHolderID="cp_content" runat="server">

    <div id="content" class="textpage">
     
          <div id="contentHeader"> 
              <h2><umbraco:Item runat="server" field="pageName"/></h2>
          </div>
         
          <umbraco:Item runat="server" field="bodyText" />
    </div>

    <div id="subNavigation">
          <umbraco:Macro Alias="umb2ndLevelNavigation" runat="server"></umbraco:Macro>
    </div>
     

    </asp:Content>

     

    Usercontrol

    <asp:Panel ID="LOGIN" runat="server" DefaultButton="cmdanmelden">
    <table align="left" height="200" width="370" >
                         <tr>
                             <td align="left" colspan="2">
                                 &nbsp;<asp:Label ID="lblbenutzername" runat="server" Text="Label">Benutzername:</asp:Label></td>
                            <td ><asp:TextBox ID="txtbenutzername" runat="server" Width="144px" CssClass="mf-input" ></asp:TextBox></td>
                        </tr>
                          <tr>
                            <td align="left" colspan="2" height="25">
                                &nbsp;<asp:Label ID="lblpassword" runat="server" Text="Password" meta:resourcekey="Password"></asp:Label></td>
                            <td height="25" ><asp:TextBox ID="txtpassword" runat="server" TextMode="Password" Width="144px" ></asp:TextBox></td>
                        </tr>
                     
                         <tr>
                            <td align="left" colspan="2" height="25">
                                &nbsp;</td>
                            <td height="25" ><asp:Button ID="cmdanmelden" runat="server" Text="login"   /></td>
                        </tr>
                   
                    </table>

    </asp:Panel>


  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 11, 2014 @ 01:25
    Jan Skovgaard
    0

    Hi Axel

    Oh...I was thinking about the C# code from your codebehind to the usercontrol :)

    /Jan

  • Axel 68 posts 96 karma points
    May 11, 2014 @ 19:59
    Axel
    0

    Partial Class UserControls_Intranet_Login
        Inherits System.Web.UI.UserControl
        Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
            If Not Page.IsPostBack Then
                Dim sWork1 As String = "Test1"
                txtbenutzername.Focus()
              
            Else
                Dim sWork2 As String = "Test1"
        
            End If
        End Sub

        Protected Sub cmdanmelden_Click(sender As Object, e As EventArgs) Handles cmdanmelden.Click
            Dim sTest As String = "Test"

    end sub

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 12, 2014 @ 09:24
    Jan Skovgaard
    0

    Hi Alex

    Could you show the complete sample with your "using" statements please? :)

    /Jan

  • Axel 68 posts 96 karma points
    May 12, 2014 @ 21:03
    Axel
    0

    Hi Jan, i dn't know why . But now it works. Sometimes it is better to sleep one night over a problem.

    Thanks for your patience

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 12, 2014 @ 22:40
    Jan Skovgaard
    0

    Hi Alex

    I know that feeling :) - Happy to hear it works.

    Have fun Umbracoing.

    /Jan

  • tuan 12 posts 32 karma points
    Jun 06, 2015 @ 12:27
    tuan
    0

    hi jan i have same problem in umbraco 7. I created dotnet usercontrol with a button and event button click. event not fire but i saw it postback. I have  tried <form runat=server> on template, but iit not work. here my usercontrol

    file ascx.cs

    using umbraco.BusinessLogic;
    using umbraco.cms.businesslogic.web;
    namespace WebApplication1.usercontrols
    {
        public partial class CreateFAQ : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {         }

            protected void _save_Click(object sender, EventArgs e)
            {

                Response.Redirect(umbraco.library.NiceUrl(1064), true);
            }
    }
    }
    file ascx
    ------------
    <fieldset>
    <asp:Button ID="_save" Text="Submit Question" runat="server"
    onclick="_save_Click" />
    </fieldset>
    -----------
    fite template
    ---------
    ....
      @{ Html.RenderPartial("
    umbTopNavigation"); }
      <form id="1" runat="server">
        @RenderBody()
      </form>
    ...
    ---------------
    can you reply [email protected]
    thank you alot.
Please Sign in or register to post replies

Write your reply to:

Draft