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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a faster way?

Status
Not open for further replies.

dpanattoni

IS-IT--Management
Jan 29, 2002
76
US
I have written a web page that displays static text and a textbox with 4 buttons below it. Depending on which button the user presses, one of 4 types of data are displayed in the text box. The text box is only a small portion of the entire web page.

The problem is that when a button is pressed, the time delay before this text box is displayed is the same as the time delay to display the entire web page. Is this what is happening? Is the entire web page being reconstructed? If so, is there a faster way for me to specify that only the textbox needs to be redisplayed?

thanks in advance.
DP
 
Take a look at the "runat" value in your ASP file. More than likely it says "server", which means there's a network roundtrip. Depending on what you're doing, you might be able to do it locally, but that might require some Javascript.

Chip H.
 
The runat is set to server, but I think I need to do it at the server since the data being displayed on a button click comes from a Data Collection object.

DP
 
Maybe it's because of my newness to this language. (I'm coming from a C background).

I have a .aspx file with an accompanying .cs codebehind page. Within the .cs file, there are the following functions:

Page_Load() {
...
}

Button1_Click() {
...
}
Button2_Click() {
...
}
Button3_Click() {
...
}
Button4_Click() {
...
}

When I pull initially pull up the page, there is approximately a 5 second wait. If I click any button, there is also the same wait period. However, If I strip the Page_Load() down to nothing, then the button clicking is instantaneous, which it should be since it's not doing much. Why does the Page_Load function being called when a button click is pressed? Is there a way to logically not execute lines of code in Page_Load the second time around?

Obviously, I have a serious misunderstanding of the "execution flow" of a C#/ASP program.

DP
 
Try turning off viewstate for the page. In most cases, you don't need it, and it adds lots of overhead. Try putting Response.Write(Request.Form) in your page_load to see what the viewstate overhead looks like.
JJH
 
Is there a way to logically not execute lines of code in Page_Load the second time around?

You probably want to wrap the code in your Page_Load in
[tt]if (!IsPostBack) { [/tt]...[tt] }[/tt]
 
Thank you.
The !IsPostBack helped a great deal. I also am now setting session state data, so that the first time in, all data is created, and then on the clicks, the data is readily accessible without recreating it everytime the button is clicked.

Thanks for your help.
DP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top