views:

165

answers:

1

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!

+1  A: 

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.

Repo Man
Good call. Thanks for the suggestions! I had kind of a head-smack moment when I realized that what I was trying to do basically explains what AJAX does. :)
Geo Ego
No problem. Personally, AJAX is kryptonite to me so I wish you luck.
Repo Man
Thanks. I've used it outside of a CMS and in Wordpress, but never in SharePoint. So far ... yeah, not fun. If it doesn't start working out for me a little better soon, I'm probably just going to have a pop-up with all of the info I need.
Geo Ego