More in this section
Forums / Sitefinity SDK / Adding a dynamic predefined value to a Form Field

Adding a dynamic predefined value to a Form Field

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 0 answered
  1. denny
    denny avatar
    13 posts
    16 Oct 2007
    05 Dec 2012
    Link to this post
    Hello, I would like the ability for my logged in users, when visiting the contact form, to have email address and name already filled out with their information.

    I have tried extending the LayoutTemplate with:

    <% textBox_write.Text = ((Telerik.Sitefinity.Security.SecurityManager.GetCurrentUserId() != Guid.Empty && Telerik.Sitefinity.Security.SecurityManager.GetUser(Telerik.Sitefinity.Security.SecurityManager.GetCurrentUserId()) != null) ? Telerik.Sitefinity.Security.SecurityManager.GetUser(Telerik.Sitefinity.Security.SecurityManager.GetCurrentUserId()).Email : ""); %>

    which, when I set a breakpoint, is working... but the text is then empty when the form loads.

    if i set it to a <%= and just show the text next to the textbox it works fine... and suggestions?

    or is there an [EMAIL] sort of value that can be set in the predefined value field for something like this?
  2. Steve
    Steve avatar
    3037 posts
    03 Dec 2008
    05 Dec 2012
    Link to this post
    What if (in your masterpage) you render out the logged in users email address...then just use some jquery to detect that and put the value into the textbox on the client?

    ...or if you dont have a masterpage just make a control to render it on the client

    Quick and easy solution anyway
  3. Victor
    Victor avatar
    94 posts
    15 Jun 2011
    28 Jan 2013 in reply to denny
    Link to this post
    Don't use "Text", use "DefaultStringValue"
3 posts, 0 answered