views:

194

answers:

1

Hey everyone,

I'm wondering if anybody has run across something similar to this before. Some quick pseudo-code to get started:

<UpdatePanel>
    <ContentTemplate>
        <ListView>
            <LayoutTemplate>
                <UpdatePanel>
                    <ContentTemplate>
                        <ItemPlaceholder />
                    </ContentTemplate>
                 </UpdatePanel>
            </LayoutTemplate>
            <ItemTemplate>
                 Some stuff goes here
            </ItemTemplate>
        </ListView>
    </ContentTemplate>
</UpdatePanel>

The main thing to take away from the above is that I have an update panel which contains a listview; and then each of the listview items is contained in its own update panel.

What I'm trying to do is when one of the ListView update panels triggers a postback, I'd want to also update one of the other ListView item update panels.

A practical implementation would be a quick survey, that has 3 questions. We'd only ask Question #3 if the user answered "Yes" to Question #1. When the page loads; it hides Q3 because it doesn't see "Yes" for Q1. When the user clicks "Yes" to Q1, I want to refresh the Q3 update panel so it now displays.

I've got it working now by refreshing the outer UpdatePanel on postback, but this seems inefficient because I don't need to re-evaluate every item; just the ones that would be affected by the prerequisite i detailed out above.

I've been grappling with setting up triggers, but i keep coming up empty mainly because I can't figure out a way to set up a trigger for the updatepanel for Q3 based off of the postback triggered by Q1.

Any suggestions out there? Am I barking up the wrong tree?

A: 

To be honest, this would probably be better done in pure javascript, hide the elements initially and show them when the question is answered. You might not be keen on that though. I've just found that the UpdatePanel is great for simple adding ajax effects, but once you start trying to do hard stuff, it gets too complex and clunky. Also, the update panel does a post back to the server each time, if you are simply turning stuff on and off in the DOM it may be better to just do javascript.

Sorry if this isn't the answer you were after, just thought I'd let you know based on my experiences (I've spent too much time fiddling with update panels when I could have just done things in Javascript)

RodH257