Saturday, March 24, 2012

Triggers

Hi to all.

So, I create buttons in a usercontrol after it i want to create triggers on this buttons in page. Is it possible?

I tried to do something like this on page

private

void FindButton(Control control)

{

foreach (Control phin control.Controls)

{

if (ph.Controls.Count > 0)

FindButton(ph);

if (phisCMSLinkButton)

{

ControlEventTrigger cet =newControlEventTrigger();

cet.ControlID = ph.ID;

cet.EventName =

"Click";

((

UpdatePanel)this.FindControl("UPContent")).Triggers.Add(cet);

}

}

}

I got an error

The ControlID property of the trigger must reference a valid control.

Exception Details:System.InvalidOperationException: The ControlID property of the trigger must reference a valid control.

Can anyone help me? :)

I'm getting the same error when trying to set my triggers to buttons inside of a Gridview. I'm still looking for the answer, but thought I'd post here in case someone came across and knew the answer for both of us.


No one knows why does it happens ?
Did anyone find out how to reference a gridview button in atlas?

for gridview or datagird : you just put an update panel around the grid markup code, hence you don't need to use Triggers to trap event. code like this:

<

atlas:UpdatePanelID="upd1"runat="server"><ContentTemplate>

<asp:GridView ...>...</asp:GridView>

</

ContentTemplate></atlas:UpdatePanel>

Ok, that all. just format your grid as you want, the update panel around the grid will help you control the event from button, hyperlink button... inside the grid and, of course, you don't need to use Triggers here.

Extending idea from those above, if you put the update panel right after the form tag, and so you don't need to trigger any events. Like this:

<form runat="server">
<atlas:UpdatePanel....>
<ContentTemplate>
...your markup code ...
</ContentTemplate>
</UpdatePanel>
</form>


tuantran:

for gridview or datagird : you just put an update panel around the grid markup code, hence you don't need to use Triggers to trap event. code like this:

<

atlas:UpdatePanelID="upd1"runat="server"><ContentTemplate>

<asp:GridView ...>...</asp:GridView>

</

ContentTemplate></atlas:UpdatePanel>

Ok, that all. just format your grid as you want, the update panel around the grid will help you control the event from button, hyperlink button... inside the grid and, of course, you don't need to use Triggers here.

Extending idea from those above, if you put the update panel right after the form tag, and so you don't need to trigger any events. Like this:

<form runat="server">
<atlas:UpdatePanel....>
<ContentTemplate>
...your markup code ...
</ContentTemplate>
</UpdatePanel>
</form>

What if you have more than one update panel? How do I reference the GridView from a separate update panel?


Please copy and paste here the mark-up code of your .aspx in that you have some seperate update panel and brieftly explain your request. I will try to find a correct solution if I can.

Regards

No comments:

Post a Comment