473,320 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

New to ASP.NET

Ok.. I am quite proficient with C# in terms of non-web apps and have decided
to take a look at ASP.NET. I am familiar with HTML, HTTP and general web
"ideas" but have not done much with ASP (more of a PHP coder myself.)

So.. I have watched quite some of WebCasts that MS has put out and have
played around a little bit on my own machine but am finding it hard to track
down "how to" type of information.

For instance, I tried populating a tree view with the list of running
services on the server.. This was pretty straight forward. Except.. Whenever
I do a postback or click on a entry in the Tree View I end up getting all
the fields added to the tree view again.. and again.. and again.. you get
the idea.

So I moved the code from Page_Load() to Page_Init() thinking that it would
then only populate the tree view when the page was first requested.. but it
didnt.. it called it every time also.

Now, where can I find information about this type of "workflow" or "program
flow" in MSDN or on the web. It is hard to know what to look for when you
are just starting out with something new.

Any good reference sites, articles or other online docs that you could
suggest that goes over the general flow of things would be great.

Thanks!

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jan 25 '06 #1
8 921
You need to become very famaliar with the
if (!Page.IsPostBack)
{
//do stuff here
}
or VB.net

if (not (Page.IsPostBack)) then

end if


"C.C. (aka Me)" <me@home.com> wrote in message
news:gM********************@comcast.com...
Ok.. I am quite proficient with C# in terms of non-web apps and have decided to take a look at ASP.NET. I am familiar with HTML, HTTP and general web
"ideas" but have not done much with ASP (more of a PHP coder myself.)

So.. I have watched quite some of WebCasts that MS has put out and have
played around a little bit on my own machine but am finding it hard to track down "how to" type of information.

For instance, I tried populating a tree view with the list of running
services on the server.. This was pretty straight forward. Except.. Whenever I do a postback or click on a entry in the Tree View I end up getting all
the fields added to the tree view again.. and again.. and again.. you get
the idea.

So I moved the code from Page_Load() to Page_Init() thinking that it would
then only populate the tree view when the page was first requested.. but it didnt.. it called it every time also.

Now, where can I find information about this type of "workflow" or "program flow" in MSDN or on the web. It is hard to know what to look for when you
are just starting out with something new.

Any good reference sites, articles or other online docs that you could
suggest that goes over the general flow of things would be great.

Thanks!

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Jan 25 '06 #2
I was looking at those just now.. Is that the norm in terms of determing if
you should fill stuff in or not?

Also, I have the following Page_Init() handler on my page. No matter what
the TreeView1.Nodes.Count property value is 0 when it is called. But it ends
up being that the nodes are still left over from the previous time the page
was requested (aka clicking on a node.) If I call TreeView1.Nodes.Clear() I
would think that it would have cleared out the old data but that is not the
case?
protected void Page_Init(object sender, EventArgs e)
{
TreeView1.Nodes.Clear(); //Seems to have no effect?
ServiceController[] svc = ServiceController.GetServices();
foreach (ServiceController aService in svc)
{
TreeNode aNode = new TreeNode(aService.ServiceName);
aNode.ChildNodes.Add(new TreeNode(aService.Status.ToString()));
TreeView1.Nodes.Add(aNode);
}
TreeView1.CollapseAll();
}

Thanks.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"sloan" <sl***@ipass.net> wrote in message
news:eh**************@TK2MSFTNGP14.phx.gbl...
You need to become very famaliar with the
if (!Page.IsPostBack)
{
//do stuff here
}
or VB.net

if (not (Page.IsPostBack)) then

end if


"C.C. (aka Me)" <me@home.com> wrote in message
news:gM********************@comcast.com...
Ok.. I am quite proficient with C# in terms of non-web apps and have

decided
to take a look at ASP.NET. I am familiar with HTML, HTTP and general web
"ideas" but have not done much with ASP (more of a PHP coder myself.)

So.. I have watched quite some of WebCasts that MS has put out and have
played around a little bit on my own machine but am finding it hard to

track
down "how to" type of information.

For instance, I tried populating a tree view with the list of running
services on the server.. This was pretty straight forward. Except..

Whenever
I do a postback or click on a entry in the Tree View I end up getting all
the fields added to the tree view again.. and again.. and again.. you get
the idea.

So I moved the code from Page_Load() to Page_Init() thinking that it
would
then only populate the tree view when the page was first requested.. but

it
didnt.. it called it every time also.

Now, where can I find information about this type of "workflow" or

"program
flow" in MSDN or on the web. It is hard to know what to look for when you
are just starting out with something new.

Any good reference sites, articles or other online docs that you could
suggest that goes over the general flow of things would be great.

Thanks!

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Jan 25 '06 #3


put your code back in Page_Load

and do somehting like this

private void Page_Load(object sender, System.EventArgs e)

{

if (!Page.IsPostBack)

{

LoadData();

}

}

private void LoadData()
{

TreeView1.Nodes.Clear(); //Seems to have no effect?
ServiceController[] svc = ServiceController.GetServices();
foreach (ServiceController aService in svc)
{
TreeNode aNode = new TreeNode(aService.ServiceName);
aNode.ChildNodes.Add(new TreeNode(aService.Status.ToString()));
TreeView1.Nodes.Add(aNode);
}
TreeView1.CollapseAll();

}
This is how I start pretty much ~every aspx page I ever write (when its
binding to some datasource).

...


"C.C. (aka Me)" <me@home.com> wrote in message
news:p5******************************@comcast.com. ..
I was looking at those just now.. Is that the norm in terms of determing if you should fill stuff in or not?

Also, I have the following Page_Init() handler on my page. No matter what
the TreeView1.Nodes.Count property value is 0 when it is called. But it ends up being that the nodes are still left over from the previous time the page was requested (aka clicking on a node.) If I call TreeView1.Nodes.Clear() I would think that it would have cleared out the old data but that is not the case?
protected void Page_Init(object sender, EventArgs e)
{
TreeView1.Nodes.Clear(); //Seems to have no effect?
ServiceController[] svc = ServiceController.GetServices();
foreach (ServiceController aService in svc)
{
TreeNode aNode = new TreeNode(aService.ServiceName);
aNode.ChildNodes.Add(new TreeNode(aService.Status.ToString()));
TreeView1.Nodes.Add(aNode);
}
TreeView1.CollapseAll();
}

Thanks.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"sloan" <sl***@ipass.net> wrote in message
news:eh**************@TK2MSFTNGP14.phx.gbl...
You need to become very famaliar with the
if (!Page.IsPostBack)
{
//do stuff here
}
or VB.net

if (not (Page.IsPostBack)) then

end if


"C.C. (aka Me)" <me@home.com> wrote in message
news:gM********************@comcast.com...
Ok.. I am quite proficient with C# in terms of non-web apps and have

decided
to take a look at ASP.NET. I am familiar with HTML, HTTP and general web "ideas" but have not done much with ASP (more of a PHP coder myself.)

So.. I have watched quite some of WebCasts that MS has put out and have
played around a little bit on my own machine but am finding it hard to

track
down "how to" type of information.

For instance, I tried populating a tree view with the list of running
services on the server.. This was pretty straight forward. Except..

Whenever
I do a postback or click on a entry in the Tree View I end up getting all the fields added to the tree view again.. and again.. and again.. you get the idea.

So I moved the code from Page_Load() to Page_Init() thinking that it
would
then only populate the tree view when the page was first requested.. but
it
didnt.. it called it every time also.

Now, where can I find information about this type of "workflow" or

"program
flow" in MSDN or on the web. It is hard to know what to look for when

you are just starting out with something new.

Any good reference sites, articles or other online docs that you could
suggest that goes over the general flow of things would be great.

Thanks!

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Jan 25 '06 #4
Didn't the Mad Hatter tell Alice to start at the beginning?
Start with these documents [1-3]

As a PHP coder do you know anything about MediaWiki? [4]

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://www.microsoft.com/mspress/boo...chap/6667a.asp
[2] http://msdn2.microsoft.com/en-us/library/ms178472.aspx
[3]
http://msdn.microsoft.com/library/de.../internals.asp
[4] http://www.mediawiki.org/wiki/MediaWiki

"C.C. (aka Me)" <me@home.com> wrote in message
news:gM********************@comcast.com...
Ok.. I am quite proficient with C# in terms of non-web apps and have
decided to take a look at ASP.NET. I am familiar with HTML, HTTP and
general web "ideas" but have not done much with ASP (more of a PHP coder
myself.)

So.. I have watched quite some of WebCasts that MS has put out and have
played around a little bit on my own machine but am finding it hard to
track down "how to" type of information.

For instance, I tried populating a tree view with the list of running
services on the server.. This was pretty straight forward. Except..
Whenever I do a postback or click on a entry in the Tree View I end up
getting all the fields added to the tree view again.. and again.. and
again.. you get the idea.

So I moved the code from Page_Load() to Page_Init() thinking that it would
then only populate the tree view when the page was first requested.. but
it didnt.. it called it every time also.

Now, where can I find information about this type of "workflow" or
"program flow" in MSDN or on the web. It is hard to know what to look for
when you are just starting out with something new.

Any good reference sites, articles or other online docs that you could
suggest that goes over the general flow of things would be great.

Thanks!

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Jan 25 '06 #5
Thanks for the links.. I will check them out.

As for MediaWiki sorry.. dont know about it.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Didn't the Mad Hatter tell Alice to start at the beginning?
Start with these documents [1-3]

As a PHP coder do you know anything about MediaWiki? [4]

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://www.microsoft.com/mspress/boo...chap/6667a.asp
[2] http://msdn2.microsoft.com/en-us/library/ms178472.aspx
[3]
http://msdn.microsoft.com/library/de.../internals.asp
[4] http://www.mediawiki.org/wiki/MediaWiki

"C.C. (aka Me)" <me@home.com> wrote in message
news:gM********************@comcast.com...
Ok.. I am quite proficient with C# in terms of non-web apps and have
decided to take a look at ASP.NET. I am familiar with HTML, HTTP and
general web "ideas" but have not done much with ASP (more of a PHP coder
myself.)

So.. I have watched quite some of WebCasts that MS has put out and have
played around a little bit on my own machine but am finding it hard to
track down "how to" type of information.

For instance, I tried populating a tree view with the list of running
services on the server.. This was pretty straight forward. Except..
Whenever I do a postback or click on a entry in the Tree View I end up
getting all the fields added to the tree view again.. and again.. and
again.. you get the idea.

So I moved the code from Page_Load() to Page_Init() thinking that it
would then only populate the tree view when the page was first
requested.. but it didnt.. it called it every time also.

Now, where can I find information about this type of "workflow" or
"program flow" in MSDN or on the web. It is hard to know what to look for
when you are just starting out with something new.

Any good reference sites, articles or other online docs that you could
suggest that goes over the general flow of things would be great.

Thanks!

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Jan 25 '06 #6
On Wed, 25 Jan 2006 15:24:31 -0500, C.C. (aka Me) wrote:
For instance, I tried populating a tree view with the list of running
services on the server.. This was pretty straight forward. Except.. Whenever
I do a postback or click on a entry in the Tree View I end up getting all
the fields added to the tree view again.. and again.. and again.. you get
the idea.

So I moved the code from Page_Load() to Page_Init() thinking that it would
then only populate the tree view when the page was first requested.. but it
didnt.. it called it every time also.


There are several ways to handle this. By default ASP enables a controls
viewstate. Viewstate is a hidden input control that other controls
serialize their data to in order to maintain state from one postback to the
next. If you ahve a lot of controls, this can greatly bloat your page.
You should disable viewstate on any controls that don't need it, and you
should seriously consider whether you need it on controls you think might.

Now, what's happening here is that your tree control is serializing it's
data to viewstate, then when you load the page on postback, it's reloading
its state and then you are reloading it as well in your page_load.

So, the two basic solutions are:

1) use viewstate and then check for postback in your page_load, and then
don't load it if it's a postback.

2) turn off viewstate and load the control yourself every time.

The 1st method can really bloat your html if your tree contains a lot of
data. It also can explose properties of your tree state you might not want
exposed, since it serializes *ALL* of the properties of the control.

The 2nd method can put a large strain on your data source, but with
cacheing and other techniques, you can allieviate that.

I prefer the 2nd method for most things, unless it's a VERY expensive query
that isn't cacheable because I don't like large viewstates.
Jan 27 '06 #7
On Wed, 25 Jan 2006 15:42:21 -0500, C.C. (aka Me) wrote:
Also, I have the following Page_Init() handler on my page. No matter what
the TreeView1.Nodes.Count property value is 0 when it is called.


This is likely because the de-serialization code for the viewstate occurs
after the point in which your code is run. So, when your code runs, the
tree is empty, but ASP.NET will fill it with your viewstate info
afterwards.

You really need to familiarize yourself with the method and event flow of
asp.net, and understand what it's doing behind the scenes. You might want
to start with these articles:

http://www.devx.com/codemag/Article/30082/0/page/1
http://www.ondotnet.com/pub/a/dotnet...bugaspnet.html
http://www.oracle.com/technology/pub.../hull_asp.html
Jan 27 '06 #8
Very good info. This type of info is what I am looking for - but it is hard
to search for what you dont know!

Thanks for you input!

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Erik Funkenbusch" <er**@despam-funkenbusch.com> wrote in message
news:rb***************@funkenbusch.com...
On Wed, 25 Jan 2006 15:24:31 -0500, C.C. (aka Me) wrote:
For instance, I tried populating a tree view with the list of running
services on the server.. This was pretty straight forward. Except..
Whenever
I do a postback or click on a entry in the Tree View I end up getting all
the fields added to the tree view again.. and again.. and again.. you get
the idea.

So I moved the code from Page_Load() to Page_Init() thinking that it
would
then only populate the tree view when the page was first requested.. but
it
didnt.. it called it every time also.


There are several ways to handle this. By default ASP enables a controls
viewstate. Viewstate is a hidden input control that other controls
serialize their data to in order to maintain state from one postback to
the
next. If you ahve a lot of controls, this can greatly bloat your page.
You should disable viewstate on any controls that don't need it, and you
should seriously consider whether you need it on controls you think might.

Now, what's happening here is that your tree control is serializing it's
data to viewstate, then when you load the page on postback, it's reloading
its state and then you are reloading it as well in your page_load.

So, the two basic solutions are:

1) use viewstate and then check for postback in your page_load, and then
don't load it if it's a postback.

2) turn off viewstate and load the control yourself every time.

The 1st method can really bloat your html if your tree contains a lot of
data. It also can explose properties of your tree state you might not
want
exposed, since it serializes *ALL* of the properties of the control.

The 2nd method can put a large strain on your data source, but with
cacheing and other techniques, you can allieviate that.

I prefer the 2nd method for most things, unless it's a VERY expensive
query
that isn't cacheable because I don't like large viewstates.

Jan 27 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
1
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
4
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the...
1
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url ...
2
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
3
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.