SharePoint Web 部件:根据用户选择进行渲染

发布于 2024-08-14 22:54:07 字数 894 浏览 2 评论 0原文

我正在编写一个与 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
   }
}

非常感谢!

I am writing a SharePoint web part that interacts with a SQL database, allowing users to set a few parameters with some dropdownlists and pull the record for a given customer.

I would like for one of three particular HTML tables to be displayed once the customer is selected. What I am confused about is how I can render HTML after the page has already ran RenderContents. Initially, I just need the ddls and a button to be displayed so that the user can make their selections, so I have put those in the RenderContents method. Once they click the button, I'd like to display one of three tables containing the data, which would be determined by the parameters they have set. I'm not sure how to begin writing such a method, although I'm sure it would involve HtmlTextWriter. This is pseudocode to represent what I need:

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
   }
}

Thanks very much!

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

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

发布评论

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

评论(1

吃素的狼 2024-08-21 22:54:07

恐怕这是一个让AJAX尖叫的问题。以下是SharePoint 内的 ASP.NET AJAX (MSDN) 的链接。如果您用 google 搜索一下,您可能还会发现其他一些有用的信息,例如 CodePlex 上的这个

I'm afraid this is a problem that's screaming for AJAX. Here is the link to ASP.NET AJAX inside SharePoint (MSDN). If you google around you may also find some other nuggets like this one on CodePlex.

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