I have a view with one DropDown list and a text box. These two (attributes) are not belonging to a particular model.
Then How can I set the MaxLength property of the Text Box and how can I set the Mandatory validation.?
Thanks in advance.
You can use CSS to set the maxlenght
new { #maxlength="4" }
and use Jquery to do a Valitation
http://jqueryvalidation.org/documentation/
Related
I need to apply style property to my selectlistitem text, which is static in razor html.
Styled select boxes can only be done by the help of javascript libraries which usually hides the original select element and create a styled div over it which looks like a dropdown.
If you really want to show your dropdowns with a customized style, try searching in Google for "jquery select plugins".
We usually use https://select2.github.io/. Easy to use and very flexible.
In a ASP.Net MVC application I wish to show in a kendo grid column a cell () colored via a color I receive in the form #FFAABB from the controller... how can I do that?
can I just apply the color via style received in the viewbag or is there a better way?
Thanks in advance
First of all, is the color is going to be only one that is being passed from the Controller and if so then you can use Viewbag or a Static variable.
But if the colors are going to differ with each rows of the Grid then its better to pass them along the Model and use a template to set the color, please see a demo I created for the same: Column Coloring from Model
I am using colors drop down in list view.In this dropdown,From the datasource,I am able to display colors from my database.
what I want is that,In the drop down,For each value i want to display name of color and squarish box filled with this color.
I have implemented the below for displaying drop down,
<select STYLE="width:90px;height:auto" id="Flag" data-bind="value:prj_flag" data-text-field="usr_color" data-value-field="usr_id" data-source="FlagdatSource" data-role="dropdownlist"></select>
Do you know how to define it NOT using KendoUI? I mean, if you know how to do it using HTML select then you should be able implementing the same in KendoUI using template in DropDownList (check KendoUI DropDownList). Doing this, you reduce your problem to a CSS question instead of a KendoUI.
You should create your server to return not only the text of the for these colors but also the color codes. Then all you need to to is to create a template.
Here it is in action, the only difference is that it is using local data (not coming from a server).
In my ASP.NET MVC 3 project I have a master layout with a section defined. This section is responsible for displaying content in a sidebar, when it has any content assigned to it.
The problem I've encountered is the following:
I have some edit views, where both the sidebar and the main area is used for editing data. In this case the sidebar and the main body should be wrapped into one single form with a single submit button.
What is the best solution for this? The solution I came up with is that when the functionality I mentioned is necessary, I set a boolean property in my ViewBag. If this property is true, the master layout is rendered with the sidebar and the main content area wrapped in a form.
Is there a better way to this? The solution I described is a bit 'hackish' for me.
I would have two layouts. One with a seperate side-bar, and one without. Then, in the pages you need a sidebar with editable fields, you include the sidebar in your content page, not in the master.
The boolean you are using in the ViewBag can be better represented in the Model for the view of the master page. You can then include the side bar using a partial view. It would look somehting like this...
master.cshtml:
#using (Html.BeginForm("ActionName", "Controller", "POST")){
//
// Master form elements go here
//
//Side bar
#if(Model.ShowSideBar){
#Html.Partial("MySideBarPartialView" [, Model.SideBarModel ] )
#}
#}
You model (if any) should have a property that is set with the model for the side bar.
How to create a Combobox having Multiselect Capability using Jquery?
Does JQuery Combobox has this functionality or Property?
if it helps, take a look http://ivaynberg.github.io/select2/ for multi select values
Edited : I found one more link it's really great http://tameraydin.github.io/jquery-easyselect/
Combobox displays the selected value when its list of options is collapsed. You may want to use multiple selection list.
to use multiple select in combobox you will have to create your own user control using checked listbox, textbox and a button.
and on click of button just make checked list box visible and let the user select items from that checkedListBox and as user select items on it you take those values and concatenate it in textbox with comma seperated. and then again on click on button hide that list box.
as it is on : http://9perhour.co.uk/
which is asking for select technology
some good samples
for jquery:
http://abeautifulsite.net/blog/2008/04/jquery-multiselect/
http://quasipartikel.at/multiselect/
http://www.codeproject.com/KB/ajax/jqueryajax.aspx
for asp.net:
http://www.codeproject.com/KB/user-controls/MultipleSelectionDropDown.aspx
http://www.codeproject.com/KB/webforms/DataGridDropDownList.aspx
http://www.codeproject.com/KB/asp/multiselectdropdown.aspx