Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Web part variables

  Asked By: Leila    Date: Sep 20    Category: Sharepoint    Views: 4100

Does any one know how to pass a variable to a vb script webpart so that it
can display content specific to the dashboard in which it is placed. I know
how to change the news one http://www.spsfaq.com/managing.asp?postid=130 but
what about a new one which has no variables stored.



3 Answers Found

Answer #1    Answered By: Donald Torres     Answered On: Sep 20

As far as I know, the only way is to code in the ability to read from
the web  part storage piece. I believe there are posts, either here or
on the msnews newsgroup, that show how to read values from the web part

Then you'd need to change  your code to use the values stored  there
instead of hard-coded ones.

Answer #2    Answered By: Courtney Scott     Answered On: Sep 20

I'll have a look..................

Answer #3    Answered By: Jagdeep Hor     Answered On: Sep 20

I wanted to share a webpart  that I created with you.
I built this webpart to take information from the "Store the
following data for this web  Part" field in the advanced settings
area of the webpart, and use it to pull information from a database,
returning contact information.

I'll paste the code here, and make comments after:

Function GetContent(node)

Dim nodPartStorage, strPartStorage, arrPartStorage, intX,
rsPersonnel, rsPersonnel_numRows, strTempSQL, Repeat1__numRows,
Set nodPartStorage = node.selectSingleNode("PartStorage")
strPartStorage = CStr(nodPartStorage.nodeTypedValue)
arrPartStorage = split(strPartStorage,",")
getcontent = "<table border='0'>"
for intX = 0 to Ubound(arrPartStorage)
strTempSQL = strTempSQL & "Initials = '" & trim(arrPartStorage
(intX)) & "'"

Set rsPersonnel = Server.CreateObject("ADODB.Recordset")
rsPersonnel.ActiveConnection = "dsn=OurDSN;uid=foo;pwd=foo;"
rsPersonnel.Source = "SELECT ProfName, Initials, ProfDept,
rsPersonnel.CursorType = 0
rsPersonnel.CursorLocation = 2
rsPersonnel.LockType = 1
rsPersonnel_numRows = 0
Repeat1__numRows = -1
Repeat1__index = 0
rsPersonnel_numRows = rsPersonnel_numRows + Repeat1__numRows

While ((Repeat1__numRows <> 0) AND (NOT rsPersonnel.EOF))
getcontent = getcontent & "<tr><td><b><font size='2'><a
href='http://intranetlink.com/contact.asp?Initials=" & rsPersonnel
("Initials") & "' target='_blank'>" & rsPersonnel("ProfName")
& "</a>  (<a href='mailto:" & rsPersonnel("Initials")
& "@fr.com'>" & rsPersonnel("Initials") & "</a>)<br></b></font><i>"
& rsPersonnel("ProfClass") & " - " & rsPersonnel("ProfDept")
& "</i></td></tr>"

strTempSQL = ""
rsPersonnel.Source = ""
getcontent = getcontent & "</table>"

End Function

Ok, for what you need to do, the following two lines (after
declaring the variables) will grab the info you want:

Set nodPartStorage = node.selectSingleNode("PartStorage")
strPartStorage = CStr(nodPartStorage.nodeTypedValue)

What you see in my code, is an array being built from the string I
pull from the data stored. The user will be required to put a comma
delimited list of values they want used in the data connection
created later.

You can pretty much do anything you want from here... you can use it
in a data connection, to get more value from smaller bits of
information... or, you can manipulate the text, and return something
more hard coded... whatever...

I hope this helps... if I'm not making any sense, please let me
know.. I often don't make sense.

Didn't find what you were looking for? Find more on Web part variables Or get search suggestion and latest updates.