Hey look at the examples here you can just override the submit method and then access the properties and they should be filled with the chosen values on submit
Thanks but when i used that code as a guide it seems the control is comparing the GUID against the value im testing against and not the text value displayed i.e
if (Country == "Germany") ......
then its reading it as
if (Country == 2cc3c8e-fd4g-491d-8374-755446c0c4dd)
Yes it definately 1.1.12. I found that code and used it as a guide.... could be the reason why im getting the odd behaviour? To get the prevalues im using this thread as a guide - should this be ok or would i find different issues down the line?
Using this code it still doesnt work - Any ideas? Anyone? I generated a GUID and passed it in manually so not sure if thats causing an issue?
using (Umbraco.Forms.Data.Storage.PreValueStorage pvs = new Umbraco.Forms.Data.Storage.PreValueStorage())
{
var val = pvs.GetPreValue(newGuid("C81C77EE-0ACC-4561-8AFB-6E402CD4694E")).Value;
if (val == "USA")
{
using (Umbraco.Forms.Data.Storage.PreValueStorage pvs = new Umbraco.Forms.Data.Storage.PreValueStorage()) { var val = pvs.GetPreValue(newGuid("2cc3c8e-fd4g-491d-8374-755446c0c4dd")).Value; if (Country == "USA") {
That code is generated on my local machine. I then copy the dll to the app_code directory for the site.
Access control in code
I have a class which builds a form. I would like to access a dropdown list and take relevant action depending on the selection
[Field(FormPages.Registration, FormFieldsets.Details, Type = typeof(DropDownList), Caption=@"Select Country", Prevalues= new string[] {"USA", "Germany", "UK"}, Mandatory = true)]
How could i access the above control in code to get the selectedvalue?
Thanks
Comment author was deleted
Hey look at the examples here you can just override the submit method and then access the properties and they should be filled with the chosen values on submit
http://www.nibble.be/?p=205
Thanks but when i used that code as a guide it seems the control is comparing the GUID against the value im testing against and not the text value displayed i.e
if (Country == "Germany") ......
then its reading it as
if (Country == 2cc3c8e-fd4g-491d-8374-755446c0c4dd)
How could i compare against the text value?
Comment author was deleted
You could fetch it from the prevalue storage or another way would be to update the dropdownlist view so it uses the text as value
How would i update the dropdown list so it uses a text value?
Comment author was deleted
Hey you can find details here http://our.umbraco.org/projects/umbraco-pro/contour/documentation/Developer/Custom-Markup/
Thanks for that but im using Contour 1.1.12 so dont think that link would apply?
So i looked into getting the prevalue storage values and im not sure where to start from as ive seen multiple different code samples?
Comment author was deleted
Are you sure you are on 1.1.12 since code first isn't in that (only from version 3 and up)
Sure take a look at Umbraco.Forms.Data.Storage.PrevalueSourceStorage
Yes it definately 1.1.12. I found that code and used it as a guide.... could be the reason why im getting the odd behaviour? To get the prevalues im using this thread as a guide - should this be ok or would i find different issues down the line?
http://our.umbraco.org/forum/umbraco-pro/contour/12438-Getting-prevalues-through-the-API
Comment author was deleted
Yeah should still work
theres no GetAllPreValues method and GetPrevalueSource accepts a GUID but i am trying to pass in the Country i.e.
[Field(FormPages.Registration, FormFieldsets.Details, Type = typeof(DropDownList), Caption=@"Select Country", Prevalues= new string[] {"USA", "Germany", "UK"}, Mandatory = true)]
public string Country {get; set;}
Umbraco.Forms.Data.Storage.PrevalueSourceStorage preStor = new Umbraco.Forms.Data.Storage.PrevalueSourceStorage();
List<Umbraco.Forms.Data.Storage.PrevalueSourceStorage> p = preStor.GetPrevalueSource(****);
Just realsied that the namespace should be Umbraco.Forms.Data.Storage.PreValueStorage.
This has me along the right track but if my code is
[Field(FormPages.Registration, FormFieldsets.Details, Type = typeof(DropDownList), DefaultValue = "{member.Country}", Caption=@"Select Country", Prevalues= new string[] {"USA", "Germany", "UK"}, Mandatory = true)]
public string Country {get; set;}
What is a field? In other word what am i passing into GetAllPreValues();
Using this code it still doesnt work - Any ideas? Anyone? I generated a GUID and passed it in manually so not sure if thats causing an issue?
Comment author was deleted
Hey you don't need to generate a new guid, simply pass it in the guid you get
2cc3c8e-fd4g-491d-8374-755446c0c4dd in your example
Comment author was deleted
if (Country == "Germany") ......
then its reading it as
if (Country == 2cc3c8e-fd4g-491d-8374-755446c0c4dd)
So pass in Country :) and it should get you the value
Ok still getting some unusual results :(.
First heres the code incase i am doing something wrong
That code is generated on my local machine. I then copy the dll to the app_code directory for the site.
The GUIDS are different to the one above?
Comment author was deleted
Could you try
if val == "USA
That seems to have worked - whoo hoo!!!!
Ill go through a full test and if any probs will reply back. Thanks again for your help.
Comment author was deleted
Sweet glad I could help :)
is working on a reply...