Adding a dynamic predefined value to a Form Field - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Adding a dynamic predefined value to a Form Field

  • Adding a dynamic predefined value to a Form Field
  • 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?
  • 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
  • Don't use "Text", use "DefaultStringValue"