How can I do this?

M

ma

Hello,

I am new in ASP.NET. I read several books and know the concept but since
I am a C++ programmer I am lost in programming methodology in ASP.NET. Here
is my problem:



I have a page which consists of two sections. A tree view on left and a
detail view on right. The tree view would get its data from a database. For
simplicity I wrote a C# class to fill the tree with some dummy data. When
user click on any node, based on the node depth and also node content and
user name, the detail section should display some information. To do this I
created a master page. Since tree view would shows on all pages I put it on
master page. I fill the tree on master page load event.



When the user clicks on any node, I redirect the user to a new page based on
the depth of node.



Everything is working well till this point but the problem started from here
and they are:



1-Every time that user redirected to a new page, tree is populated. This
process is slow. The content of tree is not changed in any session but
master page load event is called for all child pages of this master page and
hence the tree is filled un necessarily.

2- Since the tree is populated when a new page is shown, it loses its state.

3- Since tree looses its state when user is redirected to a new page, I can
not detect what I need to show in the new page.



Now my questions:



1- Where is the best place to fill the tree view?

2- Is there any sample web program similar to what I want to create that I
can download and look at?

3- Is there any way that only detail section be rendered during a post back
and not the tree view itself? I read about AJAX and Atlas. Are they any
good? Can I use them with ASP.NET? Where can I read more about them and how
they are compared with each other?

4- Any other suggestion.



Regards
 
F

Fao, Sean

ma said:
Hello,

I am new in ASP.NET. I read several books and know the concept but since
I am a C++ programmer I am lost in programming methodology in ASP.NET. Here
is my problem:

I have a page which consists of two sections. A tree view on left and a
detail view on right. The tree view would get its data from a database. For
simplicity I wrote a C# class to fill the tree with some dummy data. When
user click on any node, based on the node depth and also node content and
user name, the detail section should display some information. To do this I
created a master page. Since tree view would shows on all pages I put it on
master page. I fill the tree on master page load event.

When the user clicks on any node, I redirect the user to a new page based on
the depth of node.

Everything is working well till this point but the problem started from here
and they are:

1-Every time that user redirected to a new page, tree is populated. This
process is slow. The content of tree is not changed in any session but
master page load event is called for all child pages of this master page and
hence the tree is filled un necessarily.

Judging by this comment, I believe that it's safe to assume that the
contents of your pages are contained within a single rendered page. In
other words, you're not using frames of any kind. If that's so, did you
remember to put the binding of the DataSource of the tree inside of a
similar block?

if (!IsPostBack)
{
...
}
2- Since the tree is populated when a new page is shown, it loses its state.

Are you using the TreeView control or is this something custom you
rolled out? Either way, hopefully the above fixes it.
3- Since tree looses its state when user is redirected to a new page, I can
not detect what I need to show in the new page.

How are you doing this, anyhow? I would recommend that your links have
a query string value containing the ID of the content you wish to
display. For example http://www.mysite.com/mypage.aspx?ContentId=12345.

Hope that helps,
 
M

Mark Rae [MVP]

Following on from Sean's comments, I wonder if you're confusing ASP.NET
MasterPages with HTML framesets - they are quite different...

With traditional HTML framesets, the user clicks a hyperlink in the 'menu'
frame and this causes a new page to be displayed in the 'main' frame.

However, MasterPages don't work like that at all. In fact, a MasterPage is
nothing more than a UserControl... MasterPages allow common look and feel
(and sometimes functionality) across several content pages - think of them
as templates. When a content page loads, it loads the MasterPage every time.
Therefore, if you have a TreeView in a MasterPage and click on one of its
nodes, it redirects to that file which in turn loads up the MasterPage...
 
M

ma

Mark Rae said:
Following on from Sean's comments, I wonder if you're confusing ASP.NET
MasterPages with HTML framesets - they are quite different...

With traditional HTML framesets, the user clicks a hyperlink in the 'menu'
frame and this causes a new page to be displayed in the 'main' frame.

However, MasterPages don't work like that at all. In fact, a MasterPage is
nothing more than a UserControl... MasterPages allow common look and feel
(and sometimes functionality) across several content pages - think of them
as templates. When a content page loads, it loads the MasterPage every
time. Therefore, if you have a TreeView in a MasterPage and click on one
of its nodes, it redirects to that file which in turn loads up the
MasterPage...

Thanks Sean and Mark.

I have a table in my master page: header, footer, treeview and detail view.
should I use frameset here? If yes how? If now how do you design such
things?
I want when user click on a node in tree, only detail view is updated and
not the whole page. Is there any sample application that shows how this can
be implemented?

Regards
 
C

ca8msm

should I use frameset here

Not if you can help it. Frames have a time and a place but generally
they are regarded as an outdated method and they can cause more
problems than necessary.

This is a scenario where an AJAX method may be useful as it allows you
to update certain parts of the page. If you haven't already seen it,
visit http://ajax.asp.net to see some samples and decide whether this
would be useful in your application.
 
M

ma

Not if you can help it. Frames have a time and a place but generally
they are regarded as an outdated method and they can cause more
problems than necessary.


This is a scenario where an AJAX method may be useful as it allows you
to update certain parts of the page. If you haven't already seen it,
visit http://ajax.asp.net to see some samples and decide whether this
would be useful in your application.

Thanks mark,I am going to study AJAX. Is there any other way to do this?
If you open MSDN on web, you can see something similar to what I want to
develop ( the difference is that right section in MSDN is a static HTML but
in my case it is a dynamic one). How that ASP.NET is working? Are they using
AJAX? how they manage to update only the right side of screen without
refreshing the whole screen?

Regards
 
B

bruce barker

they use a combination of ajax and iframes. note with an iframe you need
to write javascript to handle resizes, and content can not be displayed
outside the frame boundary, so they don't work for flyout menus.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top