public static string LabelSpinnerValidationItemCellFor <TModel, TValue>(this HtmlHelper <TModel> html,
                                                                                Expression <Func <TModel, TValue> > expression, bool excludePropertyErrors) where TModel : class
        {
            StringBuilder sb          = new StringBuilder("", HelperBaseExtensions.Capacity);
            MvcHtmlString editorFor   = html.EditorFor(expression);
            String        idEditorFor = HtmlTemplete.Html.IDControl(editorFor);

            sb.Append(HtmlTemplete.Mvc.BeginSectionItemCell());
            sb.Append(HtmlTemplete.Mvc.BeginSectionEditorLabel());
            sb.Append(html.LabelFor(expression));
            String message = ValidationMessageExtensions.ValidationMessage(html.ValidationMessageFor(expression));

            if (!String.IsNullOrEmpty(message))
            {
                if (!excludePropertyErrors)
                {
                    sb.Append(message);
                }
            }
            sb.Append(HtmlTemplete.Mvc.EndSectionEditorLabel());
            sb.Append(HtmlTemplete.Mvc.SectionEditorData(editorFor));
            sb.Append(HtmlTemplete.Html.BeginScript());
            sb.Append(HtmlTemplete.JQuery.BeginReadyFunction());
            sb.Append(HtmlTemplete.JQuery.LoadControl(idEditorFor) + ".spinner();");// {step: 0.01,numberFormat: 'n'}
            sb.Append(HtmlTemplete.JQuery.EndReadyFunction());
            sb.Append(HtmlTemplete.Html.EndScript());
            sb.Append(HtmlTemplete.Mvc.EndSectionItemCell());
            return(sb.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <typeparam name="TValue"></typeparam>
        /// <param name="html"></param>
        /// <param name="expression"></param>
        /// <param name="searchUrl">URL que debera ejecutar el control</param>
        /// <param name="queryStrings"></param>
        /// <param name="indexCell">indieces de las columas a mostrar separdas por comas</param>
        /// <param name="separator">String utilizdos para separar el valor de las columnas</param>
        /// <param name="excludePropertyErrors"></param>
        /// <returns></returns>
        public static MvcHtmlString LabelAutoCompleteValidationItemFor <TModel, TValue>(this HtmlHelper <TModel> html,
                                                                                        Expression <Func <TModel, TValue> > expression, String searchUrl, String queryStrings, String indexCell,
                                                                                        String separator, bool excludePropertyErrors) where TModel : class
        {
            MvcHtmlString label         = html.LabelFor(expression);
            MvcHtmlString textBoxEditor = html.EditorFor(expression);
            String        message       = ValidationMessageExtensions.ValidationMessage(html.ValidationMessageFor(expression));

            String idTextBoxEditor      = HtmlTemplete.Html.IDControl(textBoxEditor);
            String idLabelSelectedValue = idTextBoxEditor + "-selected-value";

            StringBuilder sb = new StringBuilder("", HelperBaseExtensions.Capacity);

            sb.Append(HtmlTemplete.Mvc.BeginSectionItem());
            sb.Append(HtmlTemplete.Mvc.SectionEditorLabel(label));
            sb.Append(HtmlTemplete.Mvc.BeginSectionEditorData());
            sb.Append(HtmlTemplete.Mvc.SectionWidget(textBoxEditor));
            sb.Append(HtmlTemplete.Mvc.EndSectionEditorData());
            sb.Append(HtmlTemplete.Mvc.BeginSectionValidation());

            sb.Append(String.Format("<div><label id='{0}'></div>", idLabelSelectedValue));

            sb.Append(!String.IsNullOrEmpty(message) && !excludePropertyErrors ? message: "");
            sb.Append(HtmlTemplete.Mvc.EndSectionValidation());


            sb.Append(HtmlTemplete.Html.BeginScript());
            sb.Append(HtmlTemplete.JQuery.BeginReadyFunction());

            sb.Append(HtmlTemplete.JQuery.FunctionParametersData(queryStrings));

            sb.Append(HtmlTemplete.JQuery.LoadControl(idTextBoxEditor));
            sb.Append(".autocomplete(mvcLocal.autocomplete.getConfig(");

            sb.Append(HtmlTemplete.JQuery.LoadControl(idLabelSelectedValue));
            sb.Append(",");
            sb.Append(HtmlTemplete.Html.EncloseComillaSimple(searchUrl));
            sb.Append(",");
            sb.Append("getParametersData");
            sb.Append(",");
            sb.Append(HtmlTemplete.Html.EncloseComillaSimple(indexCell));
            sb.Append(",");
            sb.Append(HtmlTemplete.Html.EncloseComillaSimple(separator));
            sb.Append("));");  //close mvcLocal.getAutocompleteConfig y Autocomplete

            sb.Append(HtmlTemplete.JQuery.EndReadyFunction());
            sb.Append(HtmlTemplete.Html.EndScript());

            sb.Append(HtmlTemplete.Mvc.EndSectionItem());
            return(MvcHtmlString.Create(sb.ToString()));
        }
        public static string LabelGetPesoValidationItemCellFor <TModel, TValue>(this HtmlHelper <TModel> html,
                                                                                Expression <Func <TModel, TValue> > expression, bool excludePropertyErrors) where TModel : class
        {
            MvcHtmlString editorFor   = html.EditorFor(expression);
            String        message     = ValidationMessageExtensions.ValidationMessage(html.ValidationMessageFor(expression));
            String        idEditorFor = HtmlTemplete.Html.IDControl(editorFor);
            String        buttonId    = idEditorFor + "_getpeso";

            StringBuilder sb = new StringBuilder("", HelperBaseExtensions.Capacity);

            sb.Append(HtmlTemplete.Mvc.BeginSectionItemCell());
            sb.Append("<div class='peso'>");
            sb.Append(HtmlTemplete.Mvc.BeginSectionEditorLabel());
            sb.Append(html.LabelFor(expression));

            if (!String.IsNullOrEmpty(message))
            {
                if (!excludePropertyErrors)
                {
                    sb.Append(message);
                }
            }
            sb.Append(HtmlTemplete.Mvc.EndSectionEditorLabel());
            sb.Append(HtmlTemplete.Mvc.BeginSectionEditorData());
            sb.Append(editorFor);
            sb.Append("<a href='#' id='" + buttonId + "'>Leer Peso</a>");
            sb.Append(HtmlTemplete.Mvc.EndSectionEditorData());


            sb.Append(HtmlTemplete.Html.BeginScript());
            sb.Append(HtmlTemplete.JQuery.BeginReadyFunction());

            String jqControl = HtmlTemplete.JQuery.LoadControl(buttonId);

            sb.Append(jqControl + ".button();");

            sb.Append(jqControl + ".button().click(leerPeso);");
            //sb.Append(jqControl + ".button().click(function( event ) {");

            // SCRIPT PARA LLER PESO
            //sb.Append("var balanzaAX = new ActiveXObject('Heinz.PortSerial.ActiveX.Balanza'));");

            //sb.Append("});");

            sb.Append(HtmlTemplete.JQuery.EndReadyFunction());
            sb.Append(HtmlTemplete.Html.EndScript());
            sb.Append("</div>");
            sb.Append(HtmlTemplete.Mvc.EndSectionItemCell());
            return(sb.ToString());
        }
Ejemplo n.º 4
0
        public static string LabelEditorValidationItemCellFor <TModel, TValue>(this HtmlHelper <TModel> html,
                                                                               Expression <Func <TModel, TValue> > expression, int spanCells, bool excludePropertyErrors) where TModel : class
        {
            StringBuilder sb = new StringBuilder("", HelperBaseExtensions.Capacity);

            sb.Append(HtmlTemplete.Mvc.BeginSectionItemCell(spanCells));
            sb.Append(HtmlTemplete.Mvc.BeginSectionEditorLabel());
            sb.Append(html.LabelFor(expression));
            String message = ValidationMessageExtensions.ValidationMessage(html.ValidationMessageFor(expression));

            if (!String.IsNullOrEmpty(message))
            {
                if (!excludePropertyErrors)
                {
                    sb.Append(message);
                }
            }
            sb.Append(HtmlTemplete.Mvc.EndSectionEditorLabel());
            sb.Append(HtmlTemplete.Mvc.SectionEditorData(html.EditorFor(expression)));
            sb.Append(HtmlTemplete.Mvc.EndSectionItemCell());
            return(sb.ToString());
        }