+1-888-365-2779
Try Now
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

3 posts, 0 answered
  1. denny
    denny avatar
    13 posts
    Registered:
    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
    Registered:
    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
    Registered:
    15 Jun 2011
    28 Jan 2013 in reply to denny
    Link to this post
    Don't use "Text", use "DefaultStringValue"
3 posts, 0 answered