【问题标题】:SharePoint Web Part: rendering according to user selectionSharePoint Web 部件:根据用户选择呈现
【发布时间】:2009-12-14 19:34:24
【问题描述】:

我正在编写一个与 SQL 数据库交互的 SharePoint Web 部件,允许用户使用一些下拉列表设置一些参数并为给定客户提取记录。

我希望在选择客户后显示三个特定 HTML 表格之一。我感到困惑的是如何在页面已经运行 RenderContents 之后呈现 HTML。最初,我只需要显示 ddls 和一个按钮,以便用户可以进行选择,因此我将它们放在 RenderContents 方法中。一旦他们单击按钮,我想显示包含数据的三个表之一,这将由他们设置的参数确定。我不确定如何开始编写这样的方法,尽管我确信它会涉及 HtmlTextWriter。这是代表我需要的伪代码:

protected override void RenderContents(System.Web.UI.HtmlTextWriter output)
{
    ... displays dropdownlists and button ...
   renderMachineSpecifications();
}

void renderMachineSpecifications()
{
   if (record returned according to ddls is in the range 1000-1999)
   {
        // Render table type A and fill with information from database
   }
   else if (record returned according to ddls is in the range 2000-2999)
   {
        // Render table type B and fill with information from database
   }
   else
   {
        // Output error message
   }
}

非常感谢!

【问题讨论】:

    标签: c# asp.net sharepoint web-parts render


    【解决方案1】:

    恐怕这是一个让 AJAX 尖叫的问题。这是ASP.NET AJAX inside SharePoint (MSDN) 的链接。如果您在周围搜索,您可能还会发现其他一些掘金,例如 this one on CodePlex

    【讨论】:

    • 好电话。感谢您的建议!当我意识到我试图做的基本上解释了 AJAX 的作用时,我有种头晕目眩的时刻。 :)
    • 没问题。就我个人而言,AJAX 对我来说是氪石,所以我祝你好运。
    • 谢谢。我在 CMS 之外和 Wordpress 中使用过它,但从未在 SharePoint 中使用过。到目前为止......是的,不好玩。如果它没有很快开始对我好一点,我可能会弹出一个包含我需要的所有信息的弹出窗口。
    猜你喜欢
    • 1970-01-01
    • 2012-06-22
    • 1970-01-01
    • 2022-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-29
    • 1970-01-01
    相关资源
    最近更新 更多