当前位置: 首页>>代码示例>>C#>>正文


C# UrlBuilder.AddQueryString方法代码示例

本文整理汇总了C#中UrlBuilder.AddQueryString方法的典型用法代码示例。如果您正苦于以下问题:C# UrlBuilder.AddQueryString方法的具体用法?C# UrlBuilder.AddQueryString怎么用?C# UrlBuilder.AddQueryString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UrlBuilder的用法示例。


在下文中一共展示了UrlBuilder.AddQueryString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildUrl

        public string BuildUrl(NameValueCollection attributes = null)
        {

            Func<string, Func<string>, string> getValue = (key, func) =>
            {
                var value = attributes.AllKeys.Any(x => x == key) ? attributes[key] : func();
                attributes.Remove(key);
                return value;
            };

            UrlBuilder builder = new UrlBuilder(Url);

            var query = getValue("query", () => Query);
            var anchor = getValue("anchor", () => Anchor);
            
            if (query.IsNotNullOrEmpty())
                builder.AddQueryString(query);

            return UrlFormat.Formatted(builder.ToString(), anchor.IsNullOrEmpty() ? "" : "#" + anchor);
        }
开发者ID:JamesHay,项目名称:Glass.Mapper,代码行数:20,代码来源:Link.cs

示例2: RegisterListTab


//.........这里部分代码省略.........
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -96,
                        Image32By32Left = -352,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButCreateColumn"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButCreateColumn"),
                        TemplateAlias = "c2",
                    };
            customViewsGroup.Controls.Add(btnCreateColumn);

            var btnNavigateUp =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.CustomViews.Controls.NavigateUp")
                    {
                        Sequence = 30,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButNavigateUp"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = 0,
                        Image16By16Left = -56,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -64,
                        Image32By32Left = 0,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButNavigateUp"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButNavigateUp"),
                        TemplateAlias = "c2",
                    };

            var rootFolder = Page.Request.QueryString["RootFolder"];
            if (!string.IsNullOrEmpty(rootFolder))
            {
                var folder = SPContext.Current.Web.GetFolder(rootFolder);
                if (folder.ParentFolder != null && folder.UniqueId != List.RootFolder.UniqueId)
                {
                    var urlBuilder = new UrlBuilder(Page.Request.RawUrl);
                    urlBuilder.AddQueryString("RootFolder", folder.ParentFolder.ServerRelativeUrl);
                    urlBuilder.RemoveAllFilterQueryString();
                    urlBuilder.RemoveQueryString("Source");

                    btnNavigateUp.Command =
                        new SPRibbonCommand("VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Commands.NavigateUp",
                            string.Format("window.location = '{0}';", urlBuilder));
                }
            }

            customViewsGroup.Controls.Add(btnNavigateUp);

            var shareGroup = new RibbonGroup("VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Share")
                                 {
                                     Sequence = 50,
                                     Title = LocalizationHelper.GetStringFromCoreResource("cui_GrpShare"),
                                     Image32By32Popup = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                                     Image32By32PopupLeft = -448,
                                     Image32By32PopupTop = -256,
                                     GroupTemplate = RibbonGroupTemplate.Flexible2
                                 };
            shareGroup.MaxSizes.Add(new RibbonMaxSize("Ribbon.List.Scaling.Share.MaxSize")
                                        {Sequence = 40, Group = shareGroup, Size = RibbonSize.LargeLarge});
            shareGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.Share.MediumMedium")
                                      {Sequence = 90, Group = shareGroup, Size = RibbonSize.MediumMedium});
            shareGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.Share.Popup")
                                      {Sequence = 170, Group = shareGroup, Size = RibbonSize.Popup});
            listTab.Groups.Add(shareGroup);
            RegisterRibbonControls(shareGroup);

            var handlerStatement = new StringBuilder();
            handlerStatement.AppendFormat("window.location = 'mailto:?body={0}';", DataViewUtils.Escape(Page.Request.Url.OriginalString));
开发者ID:setsunafjava,项目名称:vpsp,代码行数:66,代码来源:FlatDataView.cs

示例3: GetDisplayItemLink

        protected override string GetDisplayItemLink(DataRow item, out bool showItemIndialog)
        {
            var web = SPContext.Current.Web;
            var rawUrl = SPEncode.UrlEncode(Page.Request.RawUrl);

            switch (List.BaseTemplate)
            {
                case SPListTemplateType.DiscussionBoard:
                    var discussionList = web.Lists[new Guid(item["ListId"].ToString())];
                    var discussionItem = discussionList.GetItemById(Convert.ToInt32(item["ID"]));
                    var rootFolder = SPEncode.UrlEncode(web.ServerRelativeUrl.TrimEnd('/') + "/" + discussionItem.Url);
                    showItemIndialog = false;
                    return string.Format("{0}/{1}/Flat.aspx?RootFolder={2}", web.Url, discussionList.RootFolder.Url, rootFolder);
                default:
                    var type = item["Item Type"].ToString();
                    if (type == "1;#")
                    {
                        showItemIndialog = false;
                        var urlBuilder = new UrlBuilder(Page.Request.Url);
                        urlBuilder.ClearQueryString();
                        urlBuilder.AddQueryString("RootFolder", item["ServerUrl"].ToString());
                        return urlBuilder.ToString();
                    }

                    showItemIndialog = true;
                    return string.Format("{0}/_layouts/listform.aspx?PageType=4&ListId={1}&ID={2}&Source={3}",
                                         web.Url, item["ListId"], item["ID"], rawUrl);
            }
        }
开发者ID:setsunafjava,项目名称:vpsp,代码行数:29,代码来源:FlatDataView.cs

示例4: RenderFolderCreator

        private void RenderFolderCreator(HtmlTextWriter writer)
        {
            var controlMode = SPContext.Current.FormContext.FormMode;

            writer.AddAttribute(HtmlTextWriterAttribute.Id, "part1");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formtable");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            writer.AddStyleAttribute(HtmlTextWriterStyle.MarginTop, "8px");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            // Td
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formlabel");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "190px");
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-standardheader");
            writer.RenderBeginTag(HtmlTextWriterTag.H3);    

            writer.Write("Name");

            if (controlMode != SPControlMode.Display)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Title, "This is a required field.");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formvalidation");
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(" *");
                writer.RenderEndTag(); // span    
            }

            writer.RenderEndTag(); // h3
            writer.RenderEndTag(); // td

            // Td
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formbody");
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            SPListItem folder = null;
            if (controlMode != SPControlMode.New)
            {
                folder = SPContext.Current.List.GetItemById(Convert.ToInt32(Page.Request.QueryString["ID"], CultureInfo.InvariantCulture));    
            }

            if (controlMode == SPControlMode.Display)
            {
                var viewUrl = Page.Request.QueryString["Source"];
                if (string.IsNullOrEmpty(viewUrl))
                {
                    viewUrl = SPContext.Current.List.DefaultViewUrl;
                }

                var urlBuilder = new UrlBuilder(viewUrl);
                urlBuilder.ClearQueryString();
                urlBuilder.AddQueryString("RootFolder", folder.Folder.ServerRelativeUrl);
                
                writer.AddAttribute(HtmlTextWriterAttribute.Rel, "sp_DialogLinkNavigate");
                writer.AddAttribute(HtmlTextWriterAttribute.Href, urlBuilder.ToString());
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write(SPEncode.HtmlEncode(folder.Name));
                writer.RenderEndTag(); // a
            }
            else
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Span);

                if (!Page.IsPostBack && SPContext.Current.FormContext.FormMode == SPControlMode.Edit)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Value, folder.Name);
                }
                else
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Value, folderName);
                }

                writer.AddAttribute(HtmlTextWriterAttribute.Title, "Name");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-long");
                writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID + "$onetidIOFile");
                writer.RenderBeginTag(HtmlTextWriterTag.Input);

                if (!IsValid)
                {
                    writer.Write("<br/>");
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formvalidation");
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);

                    writer.AddAttribute("role", "alert");
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);
                    writer.Write(ErrorMessage);
                    writer.RenderEndTag(); // span
                    writer.RenderEndTag(); // span
                }

//.........这里部分代码省略.........
开发者ID:bebikashg,项目名称:ttqn,代码行数:101,代码来源:ContainerWebPart.cs


注:本文中的UrlBuilder.AddQueryString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。