How to create Asp.net c# Custom control with properties select from a dropdownlist? - custom-controls

How to create Asp.net c# Custom control with properties select from a dropdownlist?
Example: I try to create my own TextBox inherit from TextBox.
It has a property named "MyOwnColor". When add custom control to Visual Studio, in the properties window, property "MyOwnColor" can input by type Text to input field.
So, what can i replace input field with a dropdownlist that has some selection are set by me?
Image: http://i.stack.imgur.com/7UaLV.jpg
I want to create properties like Border Style.
I have read some sucguest about "TypeConverter" but i don't know how to use ...
Can you help me?
I am bad at English.
Thanks...

I've asked on some forum and answer is: Use an enum.
public enum Color
{
Red,
Blue,
Green
}

Related

Adding “AllowUpload” to the landed code tab in the Bill and adjustment screen

I'm trying to add the ability to upload order lines into landed cost on the bills and adjustment screen via excel or csv. I customized the screen and set AllowUpload to True. enter image description here But i don't know how to use the [PXImport]. Can you guy show me step by step.Ex: what is the BQL and where
to put it. Be specific. Thanks
First determine the name of the DataView bound to the grid. To do that you can hold Ctl-Alt and click on the header of the grid and select Customize. It will open the customization project editor in the Screen section. Click on the top most element of the tree view in the middle to select the grid. Lookup the DataMember property on the property pane on the right side, this is the name of the DataView. While in the project editor, expand the Mode section of the property pane and set AllowUpload property to True.
Now that you know the name of the DataView you need to decorate it with the PXImport attribute. Create a Graph Extension in the code section of the project editor for this screen if you haven't already. In the Graph Extension, for a new DataView that you have created you add [PXImport(typeof(PrimaryDac)] right before the DataView declaration like this:
[PXImport(typeof(APInvoice))]
public PXSelect<MyDAC> MyDataView;
For an existing DataView from the base class you can override it in the same way:
[PXImport(typeof(APInvoice))]
public PXSelect<DAC> BaseDataView;
The Primary DAC can be found in the class declaration of the base graph:
public class APInvoiceEntry : APDataEntryGraph<APInvoiceEntry, APInvoice>, PXImportAttribute.IPXPrepareItems
Reference: Enabling Upload from Excel for the Grid

Sitecore page editor dropdown

I would kindly ask for your help :) From couple of days I am trying to achieve "linked" custom field in content editor and dropdown in page editor.
Basically I want to have dropdown in page editor and content editor which are responsible for a same thing.
In my c# code i have enums which represent directions. I created custom field which accepts assembly and class with overridden onload method and successfully populate dropdown values in the content editor. So far so good but i have no idea how to create dropdown which will represent the same functionality inside page editor.
So please give me any ideas...
Judging from your reply to my comment you need to think of the following: How is my field value being rendered onto a page?
If you are always using 1 control to do this then you just need to ensure that this control has 2 different rendering modes depending on the Context.PageMode
But as I understand it you want this dropdown to also appear when someone renders your custom field using a <sc:FieldRenderer>. In this case you'll need to look into the RenderField pipeline of Sitecore. There you find a processor called RenderWebEditing. Possibly through some manipulation here you can get your dropdown appear as you wish.

Autoit getting the name of a control

I have a VB6 control (VSFlexGrid) that I would like to get the name of. I have a class and id to reference it by and I am able to focus it but I don't know how I am suppose to retrieve the name of the control. How would I do this in Autoit?
in form design mode the grid is given a name in the property window.
you can reference it by the Name given in code.
so select the grid in the form design view and press F4 - the (name) property will be something like VSFlexGrid1 or maybe myGrid or some such..
In code you can refer to it as VSFlexGrid1.Position or VSFlexGrid1.Rows or whatever of it's properties you need to work with.
You can do more exotic things like looping through the form controls collection and detecting if it is a VSFlexGrid type, but that may be more than you are looking for.

Loop through model and create textbox for each property, in the view

I have a model with 5-6 properties. Rather than tediously writing a line of code to create a textbox in the view, is it possible to loop through all the properties in the model (which are public) and create a textbox in the view for each iteration?
Thanks
Yes you can use #Html.EditorForModel() or if you want more granular control you can generate the textboxes with the help of a little reflection:
#foreach (var property in Model.GetType().GetProperties())
{
#Html.Label(property.Name)
#Html.TextBox(property.Name)
}
There is a built-in feature for this. #Html.EditorForModel() will spit out the appropriate editor controls for each field. Read up on the "editor templates" feature in MVC to understand how this works, how to customize it, etc.

How to create a Text area in default layout

Whenever u create a View for new create thread or edit thread what u get is a text box. I need a Text area to be displayed for writing how should i go about it.
#Html.TextArea or #Html.TextAreaFor
Same as the other HTML helpers.
You can also add the following annotation to your model
[DataType(DataType.MultilineText)]
When you call EditorFor you'll get a textarea rather than a textbox.
If you're talking about actually changing the scaffolding template, you need to create your own template.

Resources