Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual studio 2005 Question TreeView webpart question

Status
Not open for further replies.

cplsplsprogrammer

Programmer
Apr 18, 2005
42
US
Hello All,

I am trying to build a webpart which using a TreeView. I had build a class to create a tree and load my tree. How can I eliminate calling the constructor when a page does a post back? Is there anyway I can do that? I think because of calling the constructor and building the tree again and again every time a page does a postback it is creating a problem.

I load the basic tree structure on page load and wanted to load the children of those nodes on the fly and so I used the eventhandler but after I catch the event and get the node and try to find the parent of the node it is givining me NULL value but it is showing the depth correctly I think the parent node for only root node will be null. Can anyone tell me if I have enable any feature or anything that I am missing.

Thanks,
Ram
 
Hey Benson,

I created a class for building a tree. I load the basic structure of the tree and load the leaf nodes dynamically when the user clicks on the node.

When I try to click on the nodes to view the details of the clicked node in another webpart the tree view webpart is doing a post back and it loads the tree again. How can I eliminate that? I cant use the IsPostBack propert in my class.

Thanks,
Ram
 
Where are you calling the class to populate your tree view initially? I would assume the page load, correct?
 
Benson,
This is how I call my webpart. TreeDisplay in zonetemplate is my class which had all the code to create a tree and handle all the tree events.
-- Ram


<form id="form1" runat="server">
<div>
<asp:webpartmanager id="WebPartManager1" runat="server">
<StaticConnections>
<asp:WebPartConnection id="con1" ProviderID="provider1"
ConsumerID="consumer1"
ConsumerConnectionPointID="Connpoint1">
</asp:WebPartConnection>
</StaticConnections>
</asp:webpartmanager>
<asp:webpartzone id="WebPartZone1" runat="server">
<zoneTemplate>
<ifield:TreeDisplay runat="Server"
ID="provider1" Title="Provider" />
<ifield:fieldconsumerwebpart2 runat="Server"
ID="consumer1" Title="Consumer"/>
</zoneTemplate>
</asp:webpartzone>
</div>
</form>
 
Do you have any code-behind? I'd wrap the piece that constructs the tree in a conditional, like

If Not IsPostback Then
...

In VS2003 help, this is at

ms-help://MS.VSCC.2003/MS.MSDNQTR.2005OCT.1033/cpref/html/frlrfSystemWebUIPageClassIsPostBackTopic.htm

HTH,

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'll have the roast duck with the mango salsa.
 
Hello Phil,

No, I dont have a code behind. It is a webpart so all I can do is call the webpart. As I dont have code behind I cannot use NotIsPostback. How do I access the link that you have sent me? Is that from your msdn downloaded on your machine?

-- Ram
 
Yeah, it's local, but you should be able to find the help on MSDN.

And.... you should be able to run code-behind in a Web part, given registration in the GAC. At least I believe that's how the SPS cookie crumbles.

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'll have the roast duck with the mango salsa.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top