Sunday, March 11, 2012

two controlEventtriggers

Write exactly that code on the server - maybe I'm not understanding your queston?


If I do not want to create a sub button1_click and button2_click how do I then change the text on the label ?

The reason is that the triggers are created dynamically.

I was thinking of something like this in page_load:

if <button1 was clicked> then

labl.text = ...

else ...

Is that possible ?


I don't think the triggers have anything to with it. Just create a method in your page:

protected sub Button_Clicked(sender as object, e as eventargs)

dim btn as Button = sender

label1.Text = btn.ID + " was clicked;"

end

And then when you generate your markup for your buttons:

<asp:Button id="somebutton" runat="server" OnClick="Button_Clicked"...>


I see, but how do I do if my button is created dynamically and I want to activate the sub Button_clicked when the button is clicked.

The Button is created as:

dim bt as new button

bt.ID = ...

bt.text = "Click me"

...

No comments:

Post a Comment