Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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.
Hi Manisha
Are you working with jquery onClick event? or userControl?
Show me your code :)
/Alex
I am working with usercontrol click event,also when I add
<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) {}
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
Thanks,
Alex
Hi Alex,
Thanks for your help and time.Its working now.
You are welcome, Manisha!!!
Have a nice day.
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.
Code of my masterpage: @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@Umbraco.RenderMacro("contactEsg")
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
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.
Manisha, basic razor syntax - https://our.umbraco.org/documentation/getting-started/design/templates/basic-razor-syntax
Templates info - https://our.umbraco.org/documentation/getting-started/design/templates/
Are you going to use webforms or MVC?
I don't know MVC,so I will use webforms.
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
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
Thanks for your help Dave,I will try this.
Hi Dave,
Its working with your usercontrol method.Thanks for help.
Manisha
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.
Totally agree with Dave, no sense to use Webforms on a new project, only MVC
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Onclick Event not working
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.
Hi Manisha
Are you working with jquery onClick event? or userControl?
Show me your code :)
/Alex
I am working with usercontrol click event,also when I add
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:
Also you have to have
Hi Alex,
Thanks for your help and time.Its working now.
You are welcome, Manisha!!!
Have a nice day.
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.
Code of my masterpage: @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@Umbraco.RenderMacro("contactEsg")
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
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.
Manisha, basic razor syntax - https://our.umbraco.org/documentation/getting-started/design/templates/basic-razor-syntax
Templates info - https://our.umbraco.org/documentation/getting-started/design/templates/
Are you going to use webforms or MVC?
I don't know MVC,so I will use webforms.
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
Than in your new master page you can use this syntax :
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
Thanks for your help Dave,I will try this.
Hi Dave,
Its working with your usercontrol method.Thanks for help.
Manisha
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
Totally agree with Dave, no sense to use Webforms on a new project, only MVC
/Alex
is working on a reply...