User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 402,974 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,722 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 299 | Replies: 2
Reply
Join Date: May 2008
Posts: 47
Reputation: pranav_jog is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
pranav_jog pranav_jog is offline Offline
Light Poster

Avoid the Page_Load after clicking dropdownlist

  #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...
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Location: istanbul
Posts: 265
Reputation: serkansendur is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 23
serkansendur's Avatar
serkansendur serkansendur is offline Offline
Posting Whiz in Training

Re: Avoid the Page_Load after clicking dropdownlist

  #2  
Jul 8th, 2008
wrap your code in the page load event handler with the following:
if(!IsPostBack)
{
//your code
}
Serkan Şendur
MCAD.NET
Reply With Quote  
Join Date: Jul 2007
Location: Surathkal
Posts: 106
Reputation: tuse is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 10
tuse's Avatar
tuse tuse is offline Offline
Junior Poster

Re: Avoid the Page_Load after clicking dropdownlist

  #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.  
  11.  

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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 7:50 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC