在 Sharepoint 中创建一个下拉列表,其中包含列表文档及其链接

发布于 2024-08-08 19:43:53 字数 139 浏览 1 评论 0原文

我希望在 default.aspx 页面上创建一个下拉列表,我希望它包含列表文档/页面,并且当选择文档/页面时,页面应重定向到所选文档/页面。

请问有什么建议可以做到这一点吗?

任何例子/样品将不胜感激?

谢谢 :)

I am looking to create a dropdown list on my default.aspx page which i want it to contain List documents/pages and when the document/page is selected the page should redirect to the selected document/page.

Any suggestions of how this can be done please?

any examples/samples would be grealy appreciated?

Thank you :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深者入戏 2024-08-15 19:43:53

AA 下拉列表具有选定值和选定文本属性。
它将显示选定的文本。

将标识文档的名称或某种字符串存储为 SelectedText 属性。存储该文档所在位置的实际超链接或该链接应将您带到 SelectedValue 中的位置。在下拉列表中将 AutoPostback 设置为 true。

在 OnSelectedIndexChanged 事件中将此代码放入:

Response.Redirect(Me.ddlLinks.SelectedValue)

AA drop down has a selectedvalue and a selected text property.
It will display the selected text.

Store the name or some sort of string that identifies the document as the SelectedText property. Store the actual hyperlink of where this document resides or where the link should take you in the SelectedValue. Set AutoPostback to true on the drop down.

In the OnSelectedIndexChanged event throw this code in:

Response.Redirect(Me.ddlLinks.SelectedValue)

谁对谁错谁最难过 2024-08-15 19:43:53

以下是我问的问题的解决方案是否还有其他人希望使用它

public partial class DropDown : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

        FillDropDown(drpList);


    }



    void FillDropDown(DropDownList drpList)
    {

        // Use using to make sure resources are released properly   
        using (SPSite site = new SPSite("http://Site/"))
        {
            using (SPWeb web = site.OpenWeb())
            {
                SPList oList = web.Lists["ListName"];
                string url = string.Empty;
                foreach (SPListItem oItem in oList.Items)
                {

                    url = site.MakeFullUrl(oItem.Url);
                   // drpList.Items.Add(new ListItem(oItem.Name, url));
                    drpList.Items.Add( new ListItem(oItem.DisplayName, url));

                }

            }
        }
    }

   void Selection_Change(Object sender, EventArgs e)
      {

          Response.Redirect(this.drpList.SelectedValue);
      }

感谢大家的帮助

Below is the solution to the question i had asked if anyone else wishes to use it

public partial class DropDown : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

        FillDropDown(drpList);


    }



    void FillDropDown(DropDownList drpList)
    {

        // Use using to make sure resources are released properly   
        using (SPSite site = new SPSite("http://Site/"))
        {
            using (SPWeb web = site.OpenWeb())
            {
                SPList oList = web.Lists["ListName"];
                string url = string.Empty;
                foreach (SPListItem oItem in oList.Items)
                {

                    url = site.MakeFullUrl(oItem.Url);
                   // drpList.Items.Add(new ListItem(oItem.Name, url));
                    drpList.Items.Add( new ListItem(oItem.DisplayName, url));

                }

            }
        }
    }

   void Selection_Change(Object sender, EventArgs e)
      {

          Response.Redirect(this.drpList.SelectedValue);
      }

Thanks everyone for your help

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文