Copied to clipboard

Flag this post as spam?

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


  • Manisha Singla 17 posts 97 karma points
    Mar 14, 2018 @ 08:22
    Manisha Singla
    0

    Hi,

    I created usercontrol and insert it as macro in template but onclick event is not working while submitting the form .Can anyone pls help.

  • Alex Skrypnyk 6131 posts 23950 karma points MVP 7x admin c-trib
    Mar 14, 2018 @ 08:49
    Alex Skrypnyk
    0

    Hi Manisha

    Are you working with jquery onClick event? or userControl?

    Show me your code :)

    /Alex

  • Manisha Singla 17 posts 97 karma points
    Mar 14, 2018 @ 09:08
    Manisha Singla
    0

    I am working with usercontrol click event,also when I add

    ,then page gets refreshed on button click and querystring being added to url. .ascx

                <div class="form-container">
            <div id="contact-form-container">
    
                  <div class="row">
                        <div class="form-group col-sm-6">
    
                            <asp:TextBox ID="txtname" runat="server" CssClass="form-control" placeholder="First Name"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" CssClass="Validation" ErrorMessage="Please Enter First Name" ControlToValidate="txtname" ValidationGroup="cont" ForeColor="#FF3300">*</asp:RequiredFieldValidator>                           
                            </div>
                         <div class="form-group col-sm-6">
                            <asp:TextBox ID="txtlname" runat="server" CssClass="form-control" placeholder="Last Name"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" CssClass="Validation" ErrorMessage="Please Enter Last Name" ControlToValidate="txtlname" ValidationGroup="cont" ForeColor="#FF3300">*</asp:RequiredFieldValidator>
    
                            </div>
                      <div class="form-group col-sm-6">
                            <asp:TextBox ID="txtemail" runat="server" CssClass="form-control" placeholder="Email"></asp:TextBox>      
                             <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" CssClass="Validation" ErrorMessage="Please Enter email" ControlToValidate="txtemail" ValidationGroup="cont" ForeColor="#FF3300">*</asp:RequiredFieldValidator>
    
                        </div>
    
                          <div class="form-group col-sm-6">
                            <asp:TextBox ID="txtphone" runat="server" CssClass="form-control" onkeypress="return isNumberKey(event);" placeholder="Phone"></asp:TextBox>      
                             <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" CssClass="Validation" ErrorMessage="Please Enter Phone" ControlToValidate="txtphone" ValidationGroup="cont" ForeColor="#FF3300">*</asp:RequiredFieldValidator>
    
                        </div>
                        <div class="form-group col-sm-6">
    
                            <asp:TextBox ID="txtorg" runat="server" CssClass="form-control"  placeholder="Organisation"></asp:TextBox>      
                             <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" CssClass="Validation" ErrorMessage="Please Enter Organization" ControlToValidate="txtorg" ValidationGroup="cont" ForeColor="#FF3300">*</asp:RequiredFieldValidator>        
                        </div>
                          <div class="form-group col-sm-6">
    
                                   <asp:DropDownList ID="ddlservices" runat="server" CssClass="form-control ServiceSelector">
                                       <asp:ListItem Text="Please select service" Selected="True" Value="0"> </asp:ListItem>
                                          <asp:ListItem Text="IT Outsourcing" Value="1"> </asp:ListItem>
                                          <asp:ListItem Text="BPO" Value="2"> </asp:ListItem>
                                          <asp:ListItem Text="Virtual employees and assistants" Value="3"> </asp:ListItem>
                                   </asp:DropDownList>
                         <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" CssClass="Validation" ErrorMessage="Please select Services" ControlToValidate="ddlservices" ValidationGroup="cont" InitialValue="-1" ForeColor="#FF3300">*</asp:RequiredFieldValidator>        
                          </div>
    
    
                                 <div class="form-group col-xs-12">
    
                                <asp:TextBox ID="txtreq" runat="server" TextMode="MultiLine" placeholder="Message"></asp:TextBox>
    
                            </div>
                        <div class="row">
                        <div class="form-group col-sm-6">
                          <div class="recaptcha-container">
                               <div id="recaptcha3">
                                    </div>
    
                          <div class="g-recaptcha" data-sitekey="6LfU40cUAAAAAPykSomUESc75QKSUWrM_ZQW0065"></div>
                        </div></div></div>
                          <div class="row">
                        <div class="col-xs-12">
                            <asp:Button ID="btnsub" runat="server" Text="Submit" OnClick="btnsub_Click" CssClass="btn btn-md btn-style-2" CausesValidation="false" />
    
                              </div>
                      </div>
                          <asp:ValidationSummary ID="val1" runat="server" ShowMessageBox="true" ShowSummary="false" ValidationGroup="cont" />
                          <asp:Label ID="Label1IT" Font-Size="16px" ForeColor="Red" Font-Names="Trebuchet MS,Tahoma,Arial,Helvetica,sans-serif"
                    runat="server"></asp:Label></div>
                      <asp:Label ID="lblMessage" runat="server" ForeColor="Red"></asp:Label>                    </div>
                      </div>
    
              </div>
            </div>
    

    Code Behind: protected void btnsub_Click(object sender, EventArgs e) {}

  • Alex Skrypnyk 6131 posts 23950 karma points MVP 7x admin c-trib
    Mar 14, 2018 @ 09:22
    Alex Skrypnyk
    0

    Umbraco 7 sets the default render engine to MVC. If you want to use usercontrols I think you have to set te render engine to use webforms.

    You can change the setting in config/umbracosettings.config:

     <templates>
        <defaultRenderingEngine>Webforms</defaultRenderingEngine>
      </templates>
    

    Also you have to have

    in your master page

    Thanks,

    Alex

  • Manisha Singla 17 posts 97 karma points
    Mar 14, 2018 @ 11:13
    Manisha Singla
    0

    Hi Alex,

    Thanks for your help and time.Its working now.

  • Alex Skrypnyk 6131 posts 23950 karma points MVP 7x admin c-trib
    Mar 14, 2018 @ 11:18
    Alex Skrypnyk
    0

    You are welcome, Manisha!!!

    Have a nice day.

  • Manisha Singla 17 posts 97 karma points
    Mar 14, 2018 @ 09:33
    Manisha Singla
    0

    Thanks for the reply,I have already done the same.Still error is coming.Could you please explain me what I have to do in masterpage.

  • Manisha Singla 17 posts 97 karma points
    Mar 14, 2018 @ 09:35
    Manisha Singla
    0

    Code of my masterpage: @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @Umbraco.RenderMacro("contactEsg")

  • Alex Skrypnyk 6131 posts 23950 karma points MVP 7x admin c-trib
    Mar 14, 2018 @ 09:38
    Alex Skrypnyk
    0

    the code you provided isn't Webforms - it's razor code

    You have to use Webforms code for using usercontrols, and be aware that it's old technique, it's better to use Razor

  • Manisha Singla 17 posts 97 karma points
    Mar 14, 2018 @ 09:46
    Manisha Singla
    0

    I am new in Umbraco7,Can you please provide me the new technique reference to use razor or usercontrol in webforms.Any help will be appreciated.

  • Alex Skrypnyk 6131 posts 23950 karma points MVP 7x admin c-trib
    Mar 14, 2018 @ 09:51
  • Manisha Singla 17 posts 97 karma points
    Mar 14, 2018 @ 09:52
    Manisha Singla
    0

    I don't know MVC,so I will use webforms.

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Mar 14, 2018 @ 10:10
    Dave Woestenborghs
    100

    For you your user control to work with PostBacks I think your template needs to be a ASPX master page.

    Seeing from this post you are using a MVC view as template.

    I haven't done webforms in ages. But I have a old umbraco website still running it

    What you need to do I think. Is the following

    • Create a folder called masterpages in the root of your website.
    • Make sure your render engine is set to webforms as mentioned in this thread.
    • Create a file in the master pages folder with the same name as your mvc view but with the extension .master
    • Delete the mvc view

    Than in your new master page you can use this syntax :

    <%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>
    
    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
        <umbraco:Macro runat="server" Alias="contactEsg" macroAlias="contactEsg" ></umbraco:Macro>
    </asp:Content>
    

    But I can't garantuee that it will work. My best option would be to move to MVC.

    Here you can find a old web post on how to move from webforms to MVC in Umbraco

    https://umbraco.com/blog/moving-from-webforms-to-mvc/

    Dave

  • Manisha Singla 17 posts 97 karma points
    Mar 14, 2018 @ 10:15
    Manisha Singla
    0

    Thanks for your help Dave,I will try this.

  • Manisha Singla 17 posts 97 karma points
    Mar 14, 2018 @ 11:12
    Manisha Singla
    0

    Hi Dave,

    Its working with your usercontrol method.Thanks for help.

    Manisha

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Mar 14, 2018 @ 11:23
    Dave Woestenborghs
    0

    Hi Manisha,

    Glad to hear it worked. But I would suggest that you switch to MVC anyway. It's much easier to get help.

    MVC was introduced in v4.9 (if i am correct) and the vast majority of the Umbraco community is using MVC.

    Dave

  • Alex Skrypnyk 6131 posts 23950 karma points MVP 7x admin c-trib
    Mar 14, 2018 @ 11:25
    Alex Skrypnyk
    1

    Totally agree with Dave, no sense to use Webforms on a new project, only MVC

    /Alex

Please Sign in or register to post replies

Write your reply to:

Draft