MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

How to get title of webPart at user control?

  Asked By: Jeramy    Date: Mar 11    Category: MOSS    Views: 1928

I am solving this problem: I need to use title of webPart at user control, but I
really don't know how I can get it.

At visual studio 2008 I made two project (WSPBuilder - webPart feauture, ASP.NET
web application - user control). Web part wrap the user control. I use this
tutorial for this: greggalipeau.com/category/sharepoint/wspbuilder/

Problem is I can't simply make a new instance of webPart in userControl and use
it's title. I am really lost at this point.

configuration(Windows server 2008 R2 x64, SharePoint 2007)



2 Answers Found

Answer #1    Answered By: Araceli Eaton     Answered On: Mar 11

Here's one way to do it:

-In your .ascx control, create a hidden label control.
-Create a public property which gets and sets the value of this hidden label.
-When you instantiate the .ascx from your web part, set this public property
with the web part title.

Answer #2    Answered By: Nisarg Kapadia     Answered On: Mar 11

Normally, your web part code inherits from the web part class, like

class mywebpart : WebPart

Then the webpart title becomes an attribute of your class. To use it, just refer
to it as

string _myTitle = this.Title;

Didn't find what you were looking for? Find more on How to get title of webPart at user control? Or get search suggestion and latest updates.