Copied to clipboard

Flag this post as spam?

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


  • syn-rg 282 posts 425 karma points
    Oct 04, 2012 @ 09:24
    syn-rg
    0

    Add the Umbraco siteName textstring to my .net usercontrol

    I have a text string property type that I use to display the "siteName" in the page title:

    <title><umbraco:Item runat="server" field="siteName" recursive="true" /></title>
    

    What code do I need in my .net usercontrol to add the "siteName"?

    <asp:Label ID="siteName" runat="server" Text="siteName should go here!"></asp:Label>
    

    Can anyone help?

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Oct 04, 2012 @ 18:01
    Jeroen Breuer
    0

    You could try this in the code behind or your usercontrol:

    dynamic node = new umbraco.MacroEngines.DynamicNode(umbraco.NodeFactory.Node.GetCurrent());
    siteName.Text = node._siteName; 

    Jeroen

  • syn-rg 282 posts 425 karma points
    Oct 05, 2012 @ 04:47
    syn-rg
    0

    Thanks Jeroen, how do I add this to my .ascx file?

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="emintRegister.ascx.cs" Inherits="umbraco.emintControls.usercontrols.BrandHub.emintRegister" %>
    <div id="message" runat="server"> </div>
    <div class="registration_container" id="regFrom" runat="server">
    <div style="color: Red">
    <asp:Literal ID="additionalErrors" runat="server"></asp:Literal>
    </div>
    <asp:ValidationSummary ID="ValidationSummary" runat="server" ValidationGroup="Registration" HeaderText="You received the following errors:" ShowSummary="False"></asp:ValidationSummary>
    <div class="employee">
    <h3>Are you an employee of <asp:Label ID="companyName1" runat="server" Text="companyName"></asp:Label>?</h3>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td class="col1"><p><strong>Are you an employee of <asp:Label ID="companyName2" runat="server" Text="companyName"></asp:Label>?</strong></p></td>
    <td class="col2"><asp:RadioButtonList ID="isAnEmployee" runat="server" RepeatLayout="Flow" RepeatColumns="2" CssClass="isEmployee">
    <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
    <asp:ListItem Text="No" Value="2"></asp:ListItem>
    </asp:RadioButtonList></td>
    <td class="col3">&nbsp;</td>
    </tr>
    </table>
    </div>
    <div class="aboutyou">
    <h3>About you</h3>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td class="col1"><p><strong>First name</strong> (required)</p></td>
    <td class="col2"><asp:TextBox class="long_input" ID="givenNames" runat="server" MaxLength="30"></asp:TextBox></td>
    <td class="col3"><asp:RequiredFieldValidator ID="givenNamesRequired" runat="server" ErrorMessage="Please enter first name" ControlToValidate="givenNames" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ValidationExpression="^[a-zA-Z '_&,().-]{1,30}$" ID="givenNameValid" runat="server" ErrorMessage="First name is not valid" ControlToValidate="givenNames" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator></td>
    </tr>
    <tr>
    <td class="col1"><p><strong>Last name</strong> (required)</p></td>
    <td class="col2"><asp:TextBox class="long_input" ID="familyName" runat="server" MaxLength="30"></asp:TextBox></td>
    <td class="col3"><asp:RequiredFieldValidator ID="familyNameRequired" runat="server" ErrorMessage="Please enter last name" ControlToValidate="familyName" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ValidationExpression="^[a-zA-Z '_&,().-]{1,30}$" ID="familyNameValid" runat="server" ErrorMessage="Family name is not valid" ControlToValidate="familyName" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator></td>
    </tr>
    </table>
    </div>
    <div class="yourdetails">
    <h3>Your details</h3>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr id="emailMessage1">
    <td colspan="3"><p class="details"> All full-time and temporary Brand contractors, with an [[email protected]] email address must register as an employee.</p></td>
    </tr>
    <tr id="emailMessageSubBrand">
    <td colspan="3"><p class="details"> If your email ends with [[email protected]], please check this box:
    <input name="subbrand" id="subbrand" type="checkbox" runat="server" class="subbrand" />
    </p></td>
    </tr>
    <tr id="emailTr">
    <td class="col1"><p><strong>Email address prefix</strong> (required)</p></td>
    <td class="col2"><div class="employeeEmail">
    <div class="employeeEmailAddress">
    <asp:TextBox class="long_input employeeEmail" ID="employeeEmail" runat="server" MaxLength="250"></asp:TextBox>
    </div>
    <div class="emailSuffix">
    <p class="details" style="color: #999;" id="currentEmployeeEmail">@brand.com</p>
    </div>
    </div></td>
    <td class="col3"><asp:RequiredFieldValidator ID="employeeEmailRequired" runat="server" ErrorMessage="Please enter your email address" ControlToValidate="employeeEmail" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ValidationExpression="^[a-zA-Z '_&,().-]{1,30}$" ID="employeeEmailValid" runat="server" ErrorMessage="Email is not valid" ControlToValidate="employeeEmail" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator>
    <p class="details"> This is also your username</p></td>
    </tr>
    <tr id="employeeEmailMessage2">
    <td colspan="3"><p class="details"> Please do not copy and paste your email address prefix into the <b>Retype email address prefix</b> field. <br>
    Incorrectly typed email addresses cannot be verified and will not be given access.</p></td>
    </tr>
    <tr id="employeeEmailRetype">
    <td class="col1"><p><strong>Retype email address prefix</strong> (required)</p></td>
    <td class="col2"><div class="employeeEmail">
    <div class="employeeEmailAddress">
    <asp:TextBox class="long_input employeeEmailConfirm" ID="employeeEmailConfirm" runat="server" MaxLength="250"></asp:TextBox>
    </div>
    <div class="emailSuffix">
    <p class="details" style="color: #999;" id="currentEmployeeEmailConfirm"> @brand.com</p>
    </div>
    </div></td>
    <td class="col3"><asp:CompareValidator ID="employeeEmailMismatch" runat="server" ErrorMessage="Your email address must match" ControlToCompare="employeeEmail" ControlToValidate="employeeEmailConfirm" ValidationGroup="Registration" Display="Dynamic"></asp:CompareValidator>
    <asp:RegularExpressionValidator ValidationExpression="^[a-zA-Z '_&,().-]{1,30}$" ID="employeeEmailConfirmValid" runat="server" ErrorMessage="Email is not valid" ControlToValidate="employeeEmailConfirm" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator>
    <asp:RequiredFieldValidator ID="requiredemployeeEmail" runat="server" ErrorMessage="Please enter your email address" ControlToValidate="employeeEmailConfirm" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator></td>
    </tr>
    <tr id="nonemployeeEmail">
    <td class="col1"><p><strong>Email address</strong> (required)</p></td>
    <td class="col2"><asp:TextBox class="long_input email" ID="email" runat="server" MaxLength="250"></asp:TextBox></td>
    <td class="col3"><asp:RequiredFieldValidator ID="emailRequired" runat="server" ErrorMessage="Please enter your email address" ControlToValidate="email" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ValidationExpression="^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$" ID="emailValid" runat="server" ErrorMessage="Email is not valid" ControlToValidate="email" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator>
    <p class="details"> This is also your username</p></td>
    </tr>
    <tr id="nonemployeeEmailMessage">
    <td colspan="3"><p class="details"> Please do not copy and paste your email address into the <b>Retype email address</b> field. <br>
    Incorrectly typed email addresses cannot be verified and will not be given access.</p></td>
    </tr>
    <tr id="nonemployeeEmailRetype">
    <td class="col1"><p><strong>Retype email address</strong> (required)</p></td>
    <td class="col2"><asp:TextBox class="long_input emailConfirm" ID="emailConfirm" runat="server" MaxLength="250"></asp:TextBox></td>
    <td class="col3"><asp:CompareValidator ID="emailMismatch" runat="server" ErrorMessage="Your email address must match" ControlToCompare="email" ControlToValidate="emailConfirm" ValidationGroup="Registration" Display="Dynamic"></asp:CompareValidator>
    <asp:RegularExpressionValidator ValidationExpression="^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$" ID="emailConfirmValid" runat="server" ErrorMessage="Email is not valid" ControlToValidate="emailConfirm" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator>
    <asp:RequiredFieldValidator ID="requiredEmail" runat="server" ErrorMessage="Please enter your email address" ControlToValidate="emailConfirm" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator></td>
    </tr>
    <tr id="companyRow">
    <td class="col1"><p><strong>Company name</strong> (required)</p></td>
    <td class="col2"><asp:TextBox ID="company" runat="server" MaxLength="30" CssClass="long_input prefillFake companyName" Text="Please enter company name"></asp:TextBox></td>
    <td class="col3"><asp:RegularExpressionValidator ValidationExpression="^[a-zA-Z0-9 '_&,().-]{0,30}$" ID="companyValid" runat="server" ErrorMessage="Company is not valid" ControlToValidate="company" Display="Dynamic" ValidationGroup="Registration"></asp:RegularExpressionValidator>
    <asp:CompareValidator ID="companyValidator" runat="server" ErrorMessage="Please enter company name." ControlToValidate="company" Display="Dynamic" ValidationGroup="Registration" ValueToCompare="Please enter company name" Operator="NotEqual"></asp:CompareValidator>
    <p class="details"> Please enter company name</p></td>
    </tr>
    <tr>
    <td class="col1"><p><strong>Job title</strong></p></td>
    <td class="col2"><asp:TextBox class="long_input" ID="title" runat="server" MaxLength="30"></asp:TextBox></td>
    <td class="col3"><asp:RegularExpressionValidator ValidationExpression="^[\w\s]{1,30}$" ID="titleValid" runat="server" ErrorMessage="Job Title is not valid" ControlToValidate="title" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator></td>
    </tr>
    <tr id="departmentRow">
    <td class="col1"><p><strong>Department</strong> (required)</p></td>
    <td class="col2"><asp:TextBox class="long_input" ID="department" runat="server" MaxLength="30"></asp:TextBox></td>
    <td class="col3"><asp:RequiredFieldValidator ID="departmentRequired" runat="server" ErrorMessage="Please enter department" ControlToValidate="department" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ValidationExpression="^[\w\s &()+-]{1,30}$" ID="departmentValid" runat="server" ErrorMessage="Department is not valid" ControlToValidate="department" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator></td>
    </tr>
    <tr>
    <td class="col1"><p><strong>Contact phone number</strong> (required)</p></td>
    <td class="col2"><asp:TextBox class="long_input" ID="contactPhoneNumber" runat="server" MaxLength="30"></asp:TextBox></td>
    <td class="col3"><asp:RequiredFieldValidator ID="contactPhoneNumberRequired" runat="server" ErrorMessage="Please enter contact phone number" ControlToValidate="contactPhoneNumber" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ValidationExpression="^[\w\s &()+-]{1,30}$" ID="contactNumberValid" runat="server" ErrorMessage="Contact phone number is not valid" ControlToValidate="contactPhoneNumber" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator></td>
    </tr>
    <tr>
    <td class="col1"><p><strong>Alternative phone number</strong></p></td>
    <td class="col2"><asp:TextBox class="long_input" ID="alternativePhoneNumber" runat="server" MaxLength="30"></asp:TextBox></td>
    <td class="col3"><asp:RegularExpressionValidator ValidationExpression="^[\w\s &()+-]{1,30}$" ID="alternativeNumberValid" runat="server" ErrorMessage="Alternative phone number is not valid" ControlToValidate="alternativePhoneNumber" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator></td>
    </tr>
    </table>
    </div>
    <div class="referrer">
    <h3>Please enter the details of the Brand contact who referred you to this site</h3>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" id="referRows">
    <tr id="reRefer1">
    <td class="col1"><p><strong>Contact&#8217;s name</strong> (required)</p></td>
    <td class="col2"><asp:TextBox class="long_input" ID="referContactName" runat="server" MaxLength="250"></asp:TextBox></td>
    <td class="col3"><asp:RequiredFieldValidator ID="referContactNameRequired" runat="server" ErrorMessage="Please enter your contact&#8217;s name" ControlToValidate="referContactName" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ValidationExpression="^[a-zA-Z '_&,().-]{1,30}$" ID="referContactNameValid" runat="server" ErrorMessage="Contact name is not valid" ControlToValidate="referContactName" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator></td>
    </tr>
    <tr id="reRefer2">
    <td class="col1"><p><strong>Contact&#8217;s division</strong> (required)</p></td>
    <td class="col2"><asp:TextBox class="long_input" ID="referContactDivision" runat="server" MaxLength="250"></asp:TextBox></td>
    <td class="col3"><asp:RequiredFieldValidator ID="referContactDivisionRequired" runat="server" ErrorMessage="Please enter your contact&#8217;s division" ControlToValidate="referContactDivision" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ValidationExpression="^[a-zA-Z '_&,().-]{1,30}$" ID="referContactDivisionValid" runat="server" ErrorMessage="Contact division is not valid" ControlToValidate="referContactDivision" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator></td>
    </tr>
    <tr id="reRefer3">
    <td class="col1"><p><strong>Contact&#8217;s email address</strong> (required)</p></td>
    <td class="col2"><asp:TextBox class="long_input" ID="referContactEmail" runat="server" MaxLength="250"></asp:TextBox></td>
    <td class="col3"><asp:RequiredFieldValidator ID="referContactEmailRequired" runat="server" ErrorMessage="Please enter your contact&#8217;s email address" ControlToValidate="referContactEmail" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ValidationExpression="^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$" ID="referContactEmailValid" runat="server" ErrorMessage="Contact email is not valid" ControlToValidate="referContactEmail" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator></td>
    </tr>
    <tr id="reRefer4">
    <td class="col1"><p><strong>Contact&#8217;s phone number</strong> (required)</p></td>
    <td class="col2"><asp:TextBox class="long_input" ID="referContactPhoneNumber" runat="server" MaxLength="30"></asp:TextBox></td>
    <td class="col3"><asp:RequiredFieldValidator ID="referContactPhoneNumberRequired" runat="server" ErrorMessage="Please enter your contact&#8217;s phone number" ControlToValidate="referContactPhoneNumber" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ValidationExpression="^[\w\s &()+-]{1,30}$" ID="referContactNumberValid" runat="server" ErrorMessage="Contact phone number is not valid" ControlToValidate="referContactPhoneNumber" ValidationGroup="Registration" Display="Dynamic"></asp:RegularExpressionValidator></td>
    </tr>
    </table>
    </div>
    <div class="security">
    <h3>Account security</h3>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr id="passwordRow1">
    <td class="col1"><p><strong>Password</strong> (required)</p></td>
    <td class="col2"><asp:TextBox class="long_input" ID="password" runat="server" TextMode="Password"></asp:TextBox></td>
    <td class="col3"><asp:RequiredFieldValidator ID="passwordRequired" runat="server" ErrorMessage="Please enter password" ControlToValidate="password" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ID="valPassword" runat="server" ControlToValidate="password" ErrorMessage="Minimum password length is 6 characters" ValidationExpression=".{6}.*" Display="Dynamic"></asp:RegularExpressionValidator>
    <p class="details"> Must be at least 6 alphanumeric characters</p></td>
    </tr>
    <tr id="passwordRow2">
    <td class="col1"><p><strong>Retype password</strong> (required)</p></td>
    <td class="col2"><asp:TextBox class="long_input" ID="confirmPassword" runat="server" TextMode="Password"></asp:TextBox></td>
    <td class="col3"><asp:RequiredFieldValidator ID="confirmPasswordRequired" runat="server" ErrorMessage="Please enter password" ControlToValidate="confirmPassword" ValidationGroup="Registration" Display="Dynamic"></asp:RequiredFieldValidator>
    <asp:CompareValidator ID="confirmPasswordValidator" runat="server" ErrorMessage="Your password must match" ControlToCompare="password" ControlToValidate="confirmPassword" ValidationGroup="Registration" Display="Dynamic"></asp:CompareValidator>
    <asp:RegularExpressionValidator ID="confirmvalPassword" runat="server" ControlToValidate="confirmPassword" ErrorMessage="Minimum password length is 6 characters" ValidationExpression=".{6}.*" Display="Dynamic"></asp:RegularExpressionValidator></td>
    </tr>
    </table>
    </div>
    <div class="signup">
    <p class="fine_print">
    <asp:CheckBox ID="termsAndConditions" runat="server"></asp:CheckBox>
    I have read and agreed to the <a runat="server" id="termsLink" href="#" target="_blank"> Terms and Conditions</a> and <a runat="server" id="privacyLink" href="#" target="_blank"> Privacy Statement</a>. <span style="font-size: 10px; margin-left: 5px;">
    <asp:CustomValidator ID="termsRequireed" runat="server" ValidationGroup="Registration" ErrorMessage="You must agree to terms and conditions" OnServerValidate="termsRequireed_ServerValidate" ClientValidationFunction="TermsRequired"></asp:CustomValidator>
    </span></p>
    <p class="fine_print">
    <input name="newsletter" id="newsletter" type="checkbox" value="Checked" checked disabled />
    By registering, you agree to receive <strong>Brand Brand Central Updates</strong>, an email notification containing important changes relating to Brand&rsquo;s Brand Standards, templates or other materials.</p>
    <asp:Button ID="ButtonSignup" runat="server" Text="Register" OnClick="ButtonSignup_Click" ValidationGroup="Registration" Display="Dynamic" CssClass="button"></asp:Button>
    </div>
    </div>
  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Oct 07, 2012 @ 16:12
    Jeroen Breuer
    0

    Your UserControl has a code behind (emintRegister.ascx.cs). You can use this example there: 

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            dynamic node = new umbraco.MacroEngines.DynamicNode(umbraco.NodeFactory.Node.GetCurrent());
            siteName.Text = node._siteName;
        }
    }

     Jeroen

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies