I have a problem,, I have to stop one Loading class on button click. I already checked some forums related to this. But didnt find exact solution.

for example:

Public Sub LoadDropDown()
            Dim it As Integer
            For it = 0 To 1000000
                DropDownList1.Items.Add(it)
            Next
End Sub

I have to load the drop down on Load button click, and have to cancel that on cancel button click

Help me.

Thank You

Rajs

Recommended Answers

All 5 Replies

Hi,

Not sure what you mean

sub CancelButtononclick()
Mydropdownlist.items.clear
Mydropdownlist.visible =false
end sub

sub loadbuttonClick()
Dim it As Integer
For it = 0 To 1000000
DropDownList1.Items.Add(it)
Next
ENd Sub

Waddell,

But the cancel button event will work only after completing the load button event. So it will continue the loop

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
 {
  call ur function here
 }
}

Just call the function your want to run when page load in post back..
i.e:

 if (Page.IsPostBack == false)
        {
            // Function name
        }

or if you call it when it run after page load then

        if (Page.IsPostBack == true)
        {
            // function name
        }

Just make then code in button click a function and call it as you require

You can use the ViewState to indicates when you the page can load the drop down list and when shall not fill the drop down list
The set of the value of ViewState can be on the buttons click events of the buttons at your application

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.