Avoid the Page_Load after clicking dropdownlist

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 47
Reputation: pranav_jog is an unknown quantity at this point 
Solved Threads: 0
pranav_jog pranav_jog is offline Offline
Light Poster

Avoid the Page_Load after clicking dropdownlist

 
0
  #1
Jul 8th, 2008
I have a user control dropdownlist, and its intended that when a user selects any item from dropdownlist , then accordingly image is displayed on the same form.

My problem is, when i select once from dropdownlist then , the page is going through the page_load and after clicking again the second time, it again walks through page_load and diretly displayes image

My question is, is it possible to avoid the page_load in any way ? & to load when i select the item first time from the dropdownlist ??

please help me to resolve this...
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: Avoid the Page_Load after clicking dropdownlist

 
0
  #2
Jul 8th, 2008
wrap your code in the page load event handler with the following:
if(!IsPostBack)
{
//your code
}
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 169
Reputation: tuse is an unknown quantity at this point 
Solved Threads: 14
tuse's Avatar
tuse tuse is offline Offline
Junior Poster

Re: Avoid the Page_Load after clicking dropdownlist

 
0
  #3
Jul 8th, 2008
If you want the code inside the Page_load to execute just the first time the page loads and prevent it from executing subsequently, put this part of code inside an if not IsPostBack block
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.  
  3. If Not IsPostBack Then
  4.  
  5.  
  6. ' Code here that needs to be executed only on first page_load
  7.  
  8. End If
  9. End Sub
  10.  

IsPostBack is a Boolean property of a page when is set (=true) when a page is first loaded. Thus, the first time that the page loads the IsPostBack is false and for subsequent PostBacks, it is true.

Read more here: http://dotnet.tekyt.info/?p=30
My blog on .NET- http://dotnet.tekyt.info
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC