I want to store id in back of the page. in web application we are using Hiddenfield for this. but i am not getting any way in xamarin forms. how do i hold unique id on page?
Is there any way to to hide any label or any text field so that i can store ID in it.
I'm not sure what do you want to here, but why don't you just add a Label and set its IsVisible property to false? It'll act like a HiddenField.
Or you can just set the value Tag property of any of your other fields with the Unique ID.
Another way is why not use MVVM Pattern? In order for you to easily work with data, which I would recommend but will take you alot of time to set up.
But I guess what you're looking for is a quick fix, The first two would suffice.
Hope it helps!
As #mindofai says, if you use MVVM then your Id can just be a field or property of the PageModel associated with the Forms page. You don't need hidden UI elements.
If you don't find Tag property for some reasons, you can still use ClassId for bindable field or StyleId for plain text.
Related
This is my Razor view in ASP.NET MVC3 Application
#Html.DropDownListFor(m => m.Leave_Type, Model.Leave_Types, new { #class = "input-append" })
On POST when I read Model.LeaveType, it returns selected value. I want to get the selected text instead, how do I get it? I appreciate any help. Thanks a lot in advance!!
The answer is.. it depends. A drop down is just a standard HTML dropdown control, and it can only post the selected value. It will never post the text, and there is no way to change that.
Do you need the selected value as well? If so, then you can't get both like that. You would have to look up the Leave_Type text in the Leave_Types object based on the selected value returned.
If you don't need the Leave_Type, then you can simply use the text for both the value and text.
Another option might be to write some javascript that copies the selected item text to a hidden field whenever the value of the dropdown changes. Then that hidden field will be posted and you can check that.
I would, however, simply look up the value in whatever method you use to create the Leave_Types collection in the first place.
I can use: #Html.HiddenFor to hide a field on a form, however, you can still see the value of the hidden field using "view source".
Is there a way in MVC3 to hide the hidden field in view source as well - I want to completely hide the primary key from the user, but still pass it from the view to the controller via the model, when posting the form.
Any code snippet or link to an example is appreciated.
Thanks
Well, put simple no. If you intend to send the key through the form, there is no way to hide the data from the source.
As you don't mention what primary key or what kind of form data you are posting, it's hard to give any other suggestions. If it is the primary key of the user, you can of course use the login session, instead of sending the key through the form, but in any other case, I'm afraid you have to reveal the primary key through the source.
You cannot hide a field from a source.
But in certain situations you can try to do something else like not passing the ID to the view. Keep it on controller side, and use it on the form submit. Of course you need to be carefull with that but it's doable with TempData or ViewData . Here's a hint http://haacked.com/archive/2007/12/21/asp.net-mvc-helpers-for-repopulating-a-form.aspx
If you need to keep information across multiple requests, then utilize the TempData collection on the server side as it's backed by session but designed precisely to keep information for short durations. Alternatively, if you must push the data to the client via hidden or other html with zero height, then encrypt it using symmetric encryption or at least base64 encoding ( very poor man approach to keep it away from curious eyes).
I created a custom control that is binded to a a Domino Document data source. I embedded it in a page so that I can display it in a Dojo dialog. It has 2 properties: dialogId and docId. The document data source's Document ID property is set to compositeData.docId. In the page, I set the docId property to a viewScope variable, that will be set when an entry in a view is clicked. What I want to accomplish is that the dialog will display the document that the current view entry (that was clicked) represents. But it seems that the compositeData.docId is not set on partial or even full refresh. Is there a way to do this that the custom control will be binded to the document? I need to have this binding so that I can easily do a server-side validation when I submit the dialog. Or if there is another way, can you also put it here? Thanks a lot!
set the datasource as the document, and then edit mode, then you have a place to compute the doc id, i usually compute the doc id to a viewScope, that i set when i click the item in the repeat control
More details here.
I would prefer the DocId to be transfered via the custom control parameters rather than a Scope variable. Using the Scope breaks the custom control design principle of being self contained. You can use the yourCC.PropertyMap to actually update a value, so the hand over of the parameter will work - of course your control then needs to be refreshed so the data source is recomputed. Hope that helps.
could someone help me with design/understanding the problem: what I need to achieve is page with Panorama/Pivot control, where its items (panos/pivots) will be set via binding, using standard MVVM pattern. Problem is I need to have different content (different user controls) on each pano/pivot, that means If I define a panorama/pivot item template, I doom all of them to be alike, which is not what I want.
I found this question here already asked: Databound windows phone panorama with MVVM design but its still not clear to me. Many thanks.
If you have a dynamic page count on panorama/pivot you could use selector to choose what template is right according to your content.
Implementing DataTemplateSelector
Also, Data Binding Pivot to MVVM may help you too
You could add a dependency property to the user control that you want to use as a data template, a dependency property named "Type" for example and depending on that property you can change the layout of your user control (data template) - for example you could have multiple grids inside your user control and you could show and hide them depending on the type.
I've got an autocompleter in a CakePHP app that provides a dropdown list of neighborhoods to attach to a place. I'm pulling from a table 'neighborhoods' with name and id fields. I want the user to see the name of the neighborhood, and I want the app to see the id of the neighborhood and insert it into the places table. How can I make this happen?
Another way of doing this would be to storing the id. Then when a user presses submit you replace the input field's value with your stored value.
assign the correct (hidden) value to a hidden input field
This type of functionality is normally achieved with a combobox, which is like an autocomplete, with an underlying select elememt, see here