I have a page that add Items to RadioButtonList with this code :
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
RD.Read()
RBQ1.Items.Add(RD.GetString(3))
RBQ1.Items.Add(RD.GetString(4))
RBQ1.Items.Add(RD.GetString(5))
RBQ1.Items.Add(RD.GetString(6))
End Sub
When I click in any button in the same page, the entire page reload and it display 8 items in the RadioButtonList, If I click for the second time I get 12 items in the RBL…
How can I prevent the page to reload if I click in this button. ?
Thanks.
You should only add the items to the control if IsPostBack is false.
As far as not having the page reload – generally when a button is clicked you do want to submit a postback to the server so you can perform whatever action the user initiates with the button.