Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Custom Variable into WebPart

  Asked By: Shauna    Date: Oct 17    Category: Sharepoint    Views: 1870

I have a web part working that is just a simple output of some
filtered fields from a document list. But what I'm wanting to do is be
able to pass a variable to it so it on certain pages I can specify the
value the field is being filtered by.

This web part already has a form on it that you can use the form to
filter results. The important part is that when it's loaded on
particular pages, the respective content will be the default.

I'm hoping maybe just in implementing the webpart on the aspx page
there is a way field I can set. But have found no documentation on it,
most likely because I'm not sure how to search for this?

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Nathanial Mcclure     Answered On: Oct 17

Have you considered simply surfacing a custom  property for the webpart.
This would allow you to configure the variable  per instance of the
webpart when you add it to the page. You could even make the property
per instance/per user. To make a property in the webpart  available you
create a standard property in either C# or VB and then decorate it with
a compiler directive. Two attributes are required. The decoration
looks like this in C#.

[WebBrowsable(true),Personalizable(PersonalizationScope.User)]

public string Variable

{



}

 
Answer #2    Answered By: Lamar Mullins     Answered On: Oct 17

That put some light on the subject, I should be able to figure it out
from that.

 
Answer #3    Answered By: Stefan Mcbride     Answered On: Oct 17

I did this as well. It was pretty easy. For some reason, however it
wouldn't update the web  part when I clicked Apply. I had to Click okay
and save the page for my new property to be read. Any idea why this
would be?

 
Answer #4    Answered By: Lee Black     Answered On: Oct 17

Apply will save the value, but depending on what you are doing with it
may not cause a refresh of the page.

 
Answer #5    Answered By: Fred Rios     Answered On: Oct 17

You can't get the programmatically set  value of a custom  property until late in
the page life cycle. Try obtaining the value in RenderContents.

 
Didn't find what you were looking for? Find more on Custom Variable into WebPart Or get search suggestion and latest updates.




Tagged: