Wednesday, March 28, 2012

UpdatePanel - Triggers - DetailsView

I have a page that contains an UpdatePanel as following

<UpdatePanel>

<ContentTemplate>

<DetailsView>

<Fields>

<TextBox ID=""/>

<DropDownList ID=""/>

</Fields>

</DetailsView>

</ContentTemplate>

<Triggers>

...

</Triggers>

</UpdatePanel>

The triggers refer to the fields of the DetailsView by their IDs, but when viewing the page I get an error that those IDs cannot be found in the UpdatePanel.

How can I reconfigure the triggers in order to make them work?

you get the error, because the trigger cannot see the id of the fields that is inside a detailsview. what you need to do is create a textbox or button outside the detailsview and have the trigger pointing to it.

you need to add some javascript to the field that is inside the detailsview to execute the textbox or button outside the details view.

e.g.

<asp:TextBox ID="txtT1" style="display: none" runat="server" />
<asp:DetailsView ...>
<Fields><asp:TextBox ID="something ..." onchange="JavaScript ...do someothing and call textchange" runat="server" />
</asp:DetailsView
<trigger>pointing to "txtT1" ...enentName="TextChanged" ./>

something like that ... hope it helps


Is there any simpler solution? Creating outside controls for every field + js - seems like a lot of work .


Hi,

Not creating outside controls for every field + js,just ont button.

I think if your detailview is inside the updatepanel and theChildrenAsTriggers property is true, there is no need to set trigger for it.

Best Regards,

No comments:

Post a Comment