English 中文(简体)
SharePoint Web Part: rendering according to user selection
原标题:

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!

最佳回答

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.

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签