Exemplo n.º 1
0
        public static MvcHtmlString CustomerSearch <TModel, TValue>(this HtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, ECustomerSearchType ECustomerSearchTypes, string customerType)
        {
            MvcHtmlString mvcHtml     = default(MvcHtmlString);
            StringBuilder htmlBuilder = new StringBuilder();
            string        mode        = "";

            if (ECustomerSearchTypes == ECustomerSearchType.Suscription)
            {
                mode = ECustomerSearchType.Suscription.GetDescription();
            }
            else if (ECustomerSearchTypes == ECustomerSearchType.Collection)
            {
                mode = ECustomerSearchType.Collection.GetDescription();
            }
            else if (ECustomerSearchTypes == ECustomerSearchType.SubscriptionReport)
            {
                mode = ECustomerSearchType.SubscriptionReport.GetDescription();
            }

            //var items = expression.Compile()(html.ViewData.Model);
            var htmlFieldName = ExpressionHelper.GetExpressionText(expression);
            var cntrlName     = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(htmlFieldName);
            var cntrlId       = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(cntrlName);
            var value         = ModelMetadata.FromLambdaExpression(expression, html.ViewData).Model;

            htmlBuilder.AppendFormat(@"<div id='pop-up-div' class='modal fade' role='dialog'></div>");
            htmlBuilder.AppendFormat(@"<div class='box-tools'>");
            htmlBuilder.AppendFormat(@"<div class='input-group input-group-sm pull-right CommonSearchDiv'>");
            htmlBuilder.AppendFormat(@"<input class='form-control col-md-7 ' type='text' id='" + cntrlName + "'  name='" + cntrlName + "' placeholder='Customer:'  style='height: 30px' readonly='readonly'>");
            //htmlBuilder.AppendFormat(@"<input style='display:inline;' type='text' id='" + cntrlName + "' class='form-control customerName' name='" + cntrlName + "' placeholder='Search   />");
            htmlBuilder.AppendFormat(@" <div class='input-group-btn'>");
            htmlBuilder.AppendFormat(@"<button type='button' name='btncustomersearch' id='btncustomersearch' class='btn btn-default btncustomersearch' style='margin-left: -208px;height: 29px !important;' data-mode='" + mode + "' customerType='" + customerType + "'><i class='fa fa-search'></i></button>");
            htmlBuilder.AppendFormat(@"</div>");
            htmlBuilder.AppendFormat(@"</div>");
            htmlBuilder.AppendFormat(@"</div>");
            mvcHtml = MvcHtmlString.Create(htmlBuilder.ToString());

            return(mvcHtml);
        }
Exemplo n.º 2
0
 public static MvcHtmlString CustomerSearch <TModel, TValue>(this HtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, ECustomerSearchType ECustomerSearchTypes)
 {
     return(CustomerSearch(html, expression, ECustomerSearchTypes, TypeOfCustomer.Customer.GetDescription()));
 }