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 in开发者_如何学Cvolve 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.
精彩评论