Copied to clipboard

Flag this post as spam?

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


  • David 28 posts 156 karma points
    Nov 14, 2014 @ 12:41
    David
    0

    Placeholder does't work with the Dictionaryitem

    Hello Guys,

    I've wrote a contact form in Visual Studio and I need to translate the placeholder in the textboxes.
    I am using Umbraco 7.1.8 and I created there a Dictionary Item which is called Vorname.

    My Textbox:

    <asp:TextBox ID="BoxTelefon" runat="server" class="display" placeholder="?" /></asp:TextBox>

    I tried the following placeholders :

    placeholder="<umbraco:Item field="#Vorname" runat="server" />"
    placeholder="{umbraco.library:GetDictionaryItem('Vorname')}"
    placeholder="<xsl:value-of select="umbraco.library:GetDictionaryItem('Vorname')" />"

    And nothing has worked.

    Would be really nice if someone could help me.

    Sincerely David :)

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 14, 2014 @ 12:48
    Dennis Aaen
    0

    HI David,

    If you are using Umbraco 7 and  MVC try this:

    placeholder="@Umbraco.GetDictionaryValue('Vorname')"

    Hope this helps,

    /Dennis

  • David 28 posts 156 karma points
    Nov 14, 2014 @ 12:57
    David
    0

    Hi Dennis,

    thank you for your fast answer.

    Yes, I'm using Umbraco 7.
    No, I'm using Webforms and the Placeholder still doesn't works. :(

    The output of my placeholder is: @Umbraco.GetDictionaryValue('Vorname')

    Sincerely David :)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 14, 2014 @ 13:22
    Jan Skovgaard
    0

    Hi David

    You should be able to use umbraco.library.GetDictionaryItem("UserControl_Details") in your placeholder.

    So this really should work placeholder="umbraco.library.GetDictionaryItem("Vorname")"

    Make sure you reference umbraco.BuisnessLogic in your using statements.

    Hope this helps.

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 14, 2014 @ 13:23
    Jan Skovgaard
    0

    Could you show us your entire code instead of just the snippets you have been trying?

    /Jan

  • David 28 posts 156 karma points
    Nov 14, 2014 @ 13:34
    David
    0

    Hi Jan,

    it still doesnt work.
    Ok sorry. Here is my ascx file :



    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Kontaktformular.ascx.cs" Inherits="Controls_Kontaktformular" %>


    <div class="container">
    <div class="row">
    <div class="col-lg-8 col-md-10 col-md-offset-1">

    <div class="row control-group">
    <div class="form-group col-xs-12 floating-label-form-group controls">
    <label>Name</label>
    <asp:TextBox ID="BoxName" runat="server" placeholder="Vorname"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator6"
    ControlToValidate="BoxName"
    Display="Dynamic"
    Text="Ein Vorname ist erforderlich."
    runat="server" />
    <p class="help-block text-danger"></p>
    </div>
    </div>
    <div class="row control-group">
    <div class="form-group col-xs-12 floating-label-form-group controls">
    <label>Email Address</label>
    <asp:TextBox ID="BoxEMail" runat="server" class="display" placeholder="Email"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator5"
    ControlToValidate="BoxEMail"
    Text="Eine gültige E-Mail Adresse ist nötig."
    runat="server" />
    <br />
    <%-- MailBox bezieht sich auf textbox ID!! Dieses Feld wird überprüft! --%>
    <asp:RegularExpressionValidator ID="regexEmailValid" runat="server"
    ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="BoxEMail"
    ErrorMessage="Ungültige Email"></asp:RegularExpressionValidator>
    <p class="help-block text-danger"></p>
    </div>
    </div>
    <div class="row control-group">
    <div class="form-group col-xs-12 floating-label-form-group controls">
    <label>Ort</label>
    <asp:TextBox ID="BoxOrt" runat="server" class="display" placeholder="Ort"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator4"
    ControlToValidate="BoxOrt"
    Text="Ein Ort ist erforderlich."
    runat="server" />
    <p class="help-block text-danger"></p>
    </div>
    </div>
    <div class="row control-group">
    <div class="form-group col-xs-12 floating-label-form-group controls">
    <label>Phone Number</label>
    <asp:TextBox ID="BoxTelefon" runat="server" class="display" placeholder="umbraco.library.GetDictionaryItem("Vorname")" ></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
    ControlToValidate="BoxTelefon"
    Text="Eine Telefonnummer ist erforderlich."
    runat="server" />
    <p class="help-block text-danger"></p>
    </div>
    </div>
    <div class="row control-group">
    <div class="form-group col-xs-12 floating-label-form-group controls">
    <label>Message</label>
    <asp:TextBox ID="BoxNachricht" runat="server" TextMode="MultiLine" placeholder="Message"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator3"
    ControlToValidate="BoxNachricht"
    Text="Eine Nachricht ist erforderlich."
    runat="server" />
    <p class="help-block text-danger"></p>
    </div>
    </div>
    <br>
    <div id="success"></div>
    <div class="row">
    <div class="form-group col-xs-12">
    <asp:Button runat="server" text="text" ID="btnSend" >

    </asp:Button>
    <umbraco:Item field="#Deutsch" runat="server" />
    </div>
    </div>
    </div>
    </div>
    </div>



    And this is the ascx.cs file:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Net.Mail;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using umbraco.BusinessLogic;
    using umbraco;

    public partial class Controls_Kontaktformular : System.Web.UI.UserControl
    {
    ///
    /// Beim Laden der Seite wird btnSend_Click initalisiert.
    ///
    ///
    ///
    protected void Page_Load(object sender, EventArgs e)
    {
    Page.EnableViewState = true;
    btnSend.Click += btnSend_Click;
    }


    ///
    /// Wenn auf den btnsend geklickt wird.
    /// wird eine nachricht per email versendet.
    ///
    ///
    ///
    void btnSend_Click(object sender, EventArgs e)
    {
    MailMessage message = new MailMessage(
    "[email protected]",
    BoxEMail.Text,
    "Quarterly data report.",
    GetMsgTxt()
    );
    message.IsBodyHtml = true;

    SmtpClient client = new SmtpClient("localhost");


    client.Send(message);
    }

    ///
    /// Das ist der Textinhalt der Email
    ///
    ///
    public string GetMsgTxt()
    {
    string msgtxt = "";
    msgtxt += "Von: " + BoxName.Text + "\n";
    msgtxt += "Nachricht: " + BoxNachricht.Text + " " + Environment.NewLine;
    msgtxt += "Ort: " + BoxOrt.Text + " " + Environment.NewLine;
    msgtxt += "Ort: " + BoxEMail.Text + " " + Environment.NewLine;
    msgtxt += "Telefonnummer: " + BoxTelefon.Text+ Environment.NewLine;
    return msgtxt;
    }
    }

     

    I recieve an Error where my control should appear.

    Error loading userControl '~/usercontrols/Kontaktformular.ascx'

    Sincerely David :)

     

     

     

     

     

     

     

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 14, 2014 @ 13:38
    Dennis Aaen
    0

    Hi David,

    Perhaps, this blogpost from Tim can help you http://www.nibble.be/?cat=7&paged=2

    Look at the middle of the page. .net usercontrols and the umbraco dictionary 10

    Hope this helps,

    /Dennis

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 14, 2014 @ 13:39
    Jan Skovgaard
    0

    Hi David

    If you look in the /app_data/logs file can you then see some further details related to this error? it should be marked with "ERROR" in the log.

    I suspect you might need to reference the umbraco.dll in order to be able to call umbraco.library methods. But I'm not sure :)

    This blogpost http://www.richardsoeteman.net/2009/04/01/AutoAddDictionaryItemsAnotherApproach.aspx from Richard Soeteman is 5 years old, but I think it's stille the same concept for fetching the Dictionary items when using Webforms.

    /Jan

  • David 28 posts 156 karma points
    Nov 14, 2014 @ 15:38
    David
    100

    Thanks for your answers!

    I've found a solution.

    I just added a attribute in the codebehind.

    BoxName.Attributes["placeholder"] = umbraco.library.GetDictionaryItem("Vorname");

     

    Sincerely David :)

Please Sign in or register to post replies

Write your reply to:

Draft