예제 #1
0
        internal string ToJavascriptString()
        {
            System.Text.StringBuilder builder = new System.Text.StringBuilder("{");
            builder.Append(JQueryOptions.PropertyStringIfSpecified("loadingElement", this.LoadingElement));
            builder.Append(JQueryOptions.PropertyStringIfSpecified("updateTarget", this.UpdateTarget));
            builder.Append(JQueryOptions.PropertyStringIfSpecified("inputToFocus", this.InputToFocus));
            builder.Append(JQueryOptions.PropertyStringIfSpecified("data", this.Data));
            builder.Append(JQueryOptions.PropertyStringIfSpecified("confirm", this.Confirm));
            FormMethod?formMethod = this.FormMethod;

            if (((formMethod.GetValueOrDefault() != System.Web.Mvc.FormMethod.Post) ? 1 : ((!formMethod.HasValue) ? 1 : 0)) != 0)
            {
                builder.Append(string.Format("type: {0}", this.FormMethod));
            }
            InsertionMode?insertionMode = this.InsertionMode;

            if (((insertionMode.GetValueOrDefault() != System.Web.Mvc.Ajax.InsertionMode.Replace) ? 1 : ((!insertionMode.HasValue) ? 1 : 0)) != 0)
            {
                builder.Append(string.Format(" insertionMode: {0},", this.InsertionMode));
            }
            builder.Append(JQueryOptions.EventStringIfSpecified("beforeSend", this.OnBeforeSend));
            builder.Append(JQueryOptions.EventStringIfSpecified("beforeSend", this.OnBeforeSend));
            builder.Append(JQueryOptions.EventStringIfSpecified("complete", this.OnComplete));
            builder.Append(JQueryOptions.EventStringIfSpecified("error", this.OnError));
            builder.Append(JQueryOptions.EventStringIfSpecified("success", this.OnSuccess));
            builder.Append(JQueryOptions.EventStringIfSpecified("getData", this.GetData));
            builder.Append(JQueryOptions.EventStringIfSpecified("precondition", this.Precondition));
            builder.Length--;
            builder.Append(" }");
            return(builder.ToString());
        }
예제 #2
0
        private static string GenerateAjaxScript(JQueryOptions jQueryOptions, string scriptFormat)
        {
            string str = jQueryOptions.ToJavascriptString();

            return(string.Format(System.Globalization.CultureInfo.InvariantCulture, scriptFormat, new object[]
            {
                str
            }));
        }
예제 #3
0
 public JQueryForm(ViewContext viewContext, string id, JQueryOptions options)
 {
     if (viewContext == null)
     {
         throw new System.ArgumentNullException("viewContext");
     }
     this._viewContext         = viewContext;
     this._writer              = viewContext.Writer;
     this._originalFormContext = viewContext.FormContext;
     this._Id                = id;
     this._Options           = (options ?? new JQueryOptions(null, null));
     viewContext.FormContext = new FormContext();
 }
예제 #4
0
        private static JQueryOptions GetJQueryOptions(JQueryOptions jQueryOptions)
        {
            JQueryOptions result;

            if (jQueryOptions == null)
            {
                result = new JQueryOptions(null, null);
            }
            else
            {
                result = jQueryOptions;
            }
            return(result);
        }
예제 #5
0
 public static MvcHtmlString JQueryRouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, object routeValues, JQueryOptions jQueryOptions, object htmlAttributes)
 {
     return(ajaxHelper.JQueryRouteLink(linkText, routeName, new System.Web.Routing.RouteValueDictionary(routeValues), jQueryOptions, JQueryExtension.ObjectToCaseSensitiveDictionary(htmlAttributes)));
 }
예제 #6
0
 public static MvcHtmlString JQueryRouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, System.Web.Routing.RouteValueDictionary routeValues, JQueryOptions jQueryOptions)
 {
     return(ajaxHelper.JQueryRouteLink(linkText, routeName, routeValues, jQueryOptions, new System.Collections.Generic.Dictionary <string, object>()));
 }
예제 #7
0
 public static MvcHtmlString JQueryActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, JQueryOptions jQueryOptions)
 {
     return(ajaxHelper.JQueryActionLink(linkText, actionName, controllerName, null, jQueryOptions, null));
 }
예제 #8
0
 public static MvcHtmlString JQueryActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, object routeValues, JQueryOptions jQueryOptions, object htmlAttributes)
 {
     System.Web.Routing.RouteValueDictionary dictionary = new System.Web.Routing.RouteValueDictionary(routeValues);
     System.Collections.Generic.Dictionary <string, object> dictionary2 = JQueryExtension.ObjectToCaseSensitiveDictionary(htmlAttributes);
     return(ajaxHelper.JQueryActionLink(linkText, actionName, controllerName, protocol, hostName, fragment, dictionary, jQueryOptions, dictionary2));
 }
예제 #9
0
 public static JQueryForm JQueryBeginForm(this AjaxHelper ajaxHelper, string actionName, string controllerName, System.Web.Routing.RouteValueDictionary routeValues, JQueryOptions jQueryOptions)
 {
     return(ajaxHelper.JQueryBeginForm(actionName, controllerName, routeValues, jQueryOptions, null));
 }
예제 #10
0
        public static JQueryForm JQueryBeginRouteForm(this AjaxHelper ajaxHelper, string routeName, System.Web.Routing.RouteValueDictionary routeValues, JQueryOptions jQueryOptions, System.Collections.Generic.IDictionary <string, object> htmlAttributes)
        {
            string formAction = UrlHelper.GenerateUrl(routeName, null, null, routeValues ?? new System.Web.Routing.RouteValueDictionary(), ajaxHelper.RouteCollection, ajaxHelper.ViewContext.RequestContext, false);

            return(ajaxHelper.FormHelper(formAction, jQueryOptions, htmlAttributes));
        }
예제 #11
0
 public static MvcHtmlString JQueryActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, System.Web.Routing.RouteValueDictionary routeValues, JQueryOptions jQueryOptions)
 {
     return(ajaxHelper.JQueryActionLink(linkText, actionName, controllerName, routeValues, jQueryOptions, null));
 }
예제 #12
0
 public static JQueryForm JQueryBeginRouteForm(this AjaxHelper ajaxHelper, string routeName, System.Web.Routing.RouteValueDictionary routeValues, JQueryOptions jQueryOptions)
 {
     return(ajaxHelper.JQueryBeginRouteForm(routeName, routeValues, jQueryOptions, null));
 }
예제 #13
0
 public static JQueryForm JQueryBeginRouteForm(this AjaxHelper ajaxHelper, string routeName, object routeValues, JQueryOptions jQueryOptions, object htmlAttributes)
 {
     System.Collections.Generic.Dictionary <string, object> dictionary = JQueryExtension.ObjectToCaseSensitiveDictionary(htmlAttributes);
     return(ajaxHelper.JQueryBeginRouteForm(routeName, new System.Web.Routing.RouteValueDictionary(routeValues), jQueryOptions, dictionary));
 }
예제 #14
0
 public static JQueryForm JQueryBeginRouteForm(this AjaxHelper ajaxHelper, string routeName, object routeValues, JQueryOptions jQueryOptions)
 {
     return(ajaxHelper.JQueryBeginRouteForm(routeName, routeValues, jQueryOptions, null));
 }
예제 #15
0
 public static MvcHtmlString JQueryActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, JQueryOptions jQueryOptions)
 {
     return(ajaxHelper.JQueryActionLink(linkText, actionName, (object)null, jQueryOptions));
 }
예제 #16
0
 public static JQueryForm JQueryBeginForm(this AjaxHelper ajaxHelper, string actionName, System.Web.Routing.RouteValueDictionary routeValues, JQueryOptions jQueryOptions, System.Collections.Generic.IDictionary <string, object> htmlAttributes)
 {
     return(ajaxHelper.JQueryBeginForm(actionName, null, routeValues, jQueryOptions, htmlAttributes));
 }
예제 #17
0
        public static MvcHtmlString JQueryRouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, System.Web.Routing.RouteValueDictionary routeValues, JQueryOptions jQueryOptions, System.Collections.Generic.IDictionary <string, object> htmlAttributes)
        {
            if (string.IsNullOrEmpty(linkText))
            {
                throw new System.ArgumentException("MvcResources.Common_NullOrEmpty", "linkText");
            }
            string targetUrl = UrlHelper.GenerateUrl(routeName, null, null, routeValues ?? new System.Web.Routing.RouteValueDictionary(), ajaxHelper.RouteCollection, ajaxHelper.ViewContext.RequestContext, false);

            return(MvcHtmlString.Create(JQueryExtension.GenerateLink(linkText, targetUrl, JQueryExtension.GetJQueryOptions(jQueryOptions), htmlAttributes)));
        }
예제 #18
0
        private static JQueryForm FormHelper(this AjaxHelper ajaxHelper, string formAction, JQueryOptions jQueryOptions, System.Collections.Generic.IDictionary <string, object> htmlAttributes)
        {
            TagBuilder builder = new TagBuilder("form");

            builder.MergeAttributes <string, object>(htmlAttributes);
            builder.MergeAttribute("action", formAction);
            builder.MergeAttribute("method", "post");
            builder.GenerateId(string.Format("form_{0:n}", System.Guid.NewGuid()));
            ajaxHelper.ViewContext.Writer.Write(builder.ToString(TagRenderMode.StartTag));
            JQueryForm form = new JQueryForm(ajaxHelper.ViewContext, builder.Attributes["id"], jQueryOptions);

            ajaxHelper.ViewContext.FormContext.FormId = form.Id;
            return(form);
        }
예제 #19
0
 public static MvcHtmlString JQueryActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, object routeValues, JQueryOptions jQueryOptions, object htmlAttributes)
 {
     return(ajaxHelper.JQueryActionLink(linkText, actionName, null, routeValues, jQueryOptions, htmlAttributes));
 }
예제 #20
0
        public static JQueryForm JQueryBeginForm(this AjaxHelper ajaxHelper, JQueryOptions jQueryOptions)
        {
            string rawUrl = ajaxHelper.ViewContext.HttpContext.Request.RawUrl;

            return(ajaxHelper.FormHelper(rawUrl, jQueryOptions, new System.Web.Routing.RouteValueDictionary()));
        }
예제 #21
0
 public static MvcHtmlString JQueryActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, System.Web.Routing.RouteValueDictionary routeValues, JQueryOptions jQueryOptions, System.Collections.Generic.IDictionary <string, object> htmlAttributes)
 {
     return(ajaxHelper.JQueryActionLink(linkText, actionName, null, routeValues, jQueryOptions, htmlAttributes));
 }
예제 #22
0
 public static JQueryForm JQueryBeginForm(this AjaxHelper ajaxHelper, string actionName, object routeValues, JQueryOptions jQueryOptions, object htmlAttributes)
 {
     return(ajaxHelper.JQueryBeginForm(actionName, null, routeValues, jQueryOptions, htmlAttributes));
 }
예제 #23
0
        public static MvcHtmlString JQueryActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, System.Web.Routing.RouteValueDictionary routeValues, JQueryOptions jQueryOptions, System.Collections.Generic.IDictionary <string, object> htmlAttributes)
        {
            if (string.IsNullOrEmpty(linkText))
            {
                throw new System.ArgumentException("MvcResources.Common_NullOrEmpty", "linkText");
            }
            string targetUrl = UrlHelper.GenerateUrl(null, actionName, controllerName, protocol, hostName, fragment, routeValues, ajaxHelper.RouteCollection, ajaxHelper.ViewContext.RequestContext, true);

            return(MvcHtmlString.Create(JQueryExtension.GenerateLink(linkText, targetUrl, jQueryOptions, htmlAttributes)));
        }
예제 #24
0
 public static JQueryForm JQueryBeginForm(this AjaxHelper ajaxHelper, string actionName, string controllerName, object routeValues, JQueryOptions jQueryOptions)
 {
     return(ajaxHelper.JQueryBeginForm(actionName, controllerName, routeValues, jQueryOptions, null));
 }
예제 #25
0
 public static JQueryForm JQueryBeginForm(this AjaxHelper ajaxHelper, string actionName, JQueryOptions jQueryOptions)
 {
     return(ajaxHelper.JQueryBeginForm(actionName, (object)null, jQueryOptions));
 }
예제 #26
0
 private static string GenerateLink(string linkText, string targetUrl, JQueryOptions jQueryOptions, System.Collections.Generic.IDictionary <string, object> htmlAttributes)
 {
     return(string.Format("<a href=\"{0}\" onclick=\"{1}\">{2}</a>", targetUrl, JQueryExtension.GenerateAjaxScript(jQueryOptions, "$(this).ajaxLink({0});return false;"), HttpUtility.HtmlEncode(linkText)));
 }