Salah a a a Al Jasem
asked on
VB.net How to execute Page_Load One time
VB 2015
One the web page I have a list box that has 2 items added using Page_Load as follows
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ListBox1.Items.Add(New ListItem("Item1))
ListBox1.Items.Add(New ListItem("Item2))
End Sub
So the list box will have
Item1
Item2
In the same web page there is a button
Page_Load is executed every time a button is clicked
As a result List box is becoming
Item1
Item2
Item1
Item2
And Keeps on growing every time Button is clicked! I discovered that Page_Load is loaded every time the button is clicked.
Is there a way to execute Page_Load once
One the web page I have a list box that has 2 items added using Page_Load as follows
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ListBox1.Items.Add(New ListItem("Item1))
ListBox1.Items.Add(New ListItem("Item2))
End Sub
So the list box will have
Item1
Item2
In the same web page there is a button
Page_Load is executed every time a button is clicked
As a result List box is becoming
Item1
Item2
Item1
Item2
And Keeps on growing every time Button is clicked! I discovered that Page_Load is loaded every time the button is clicked.
Is there a way to execute Page_Load once
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Exact answer