Adding a dynamic predefined value to a Form Field

Posted by Community Admin on 05-Aug-2018 07:13

Adding a dynamic predefined value to a Form Field

All Replies

Posted by Community Admin on 05-Dec-2012 00:00

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?

Posted by Community Admin on 05-Dec-2012 00:00

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

Posted by Community Admin on 28-Jan-2013 00:00

Don't use "Text", use "DefaultStringValue"

This thread is closed