0

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

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by tuse
0

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

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 If Not IsPostBack Then


' Code here that needs to be executed only on first page_load

End If
End Sub

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.