Monday, March 26, 2012

Multiview inside updatepanel, updatepanel inside View?

Has anyone gotten this to work? I have a multiview inside an updatepanel, and I can switch tabs without a screen repaint. But then, in one of the views I tried to put an updatepanel to update something in that view and it started freaking out. (probably for similar reasons to the freakout when I tried to put an updatepanel inside the itemtemplate of a repeater)

For example, I want a view to enter billing information, but then I want to dynamically hide the states dropdown if you pick a country other than US, CA or AU. At first it told me that my trigger had to reference a valid control, so I set it to the name of my country dropdownlist. It accepted that but then it gave me an object expected javascript error. Quite frankly, my brain is about to explode from trying to wrap it around this stuff.

So, I'm going to skip the idea of hiding the state DDL and just have a default option "select if appropriate" and move on with my life. But consider this an FYI to you boys (and girls) on the atlas development team.

hello.

can you give more details about your scenario? it looks like you ended with an updatepanel inside another updatepanel...


An updatepanel inside a view inside a multiview inside another updatepanel. So yes, basically, an updatepanel inside an updatepanel. From what I understand you can nest updatepanels no? Or does that only work when you don't have something in the way like my view/multiview

hello again,

to be honest, i haven't tried...well, what i really don't understand is why you're dont' simply update the whole view...btw, can you build a small sample that reproduces that behavior and post it here? it'll have to be a simple page so that we can copy/paste it...


I built a simple page where the view has a button that changes a label, and that worked fine, but my dropdown does not: I want the states DDL to disappear when I select france. Keep in mind that I'm building a submission form and I don't want to lose input in any of the views (same as if I was using the wizard control but without all the overhead)

<%@. Page Language="VB" AutoEventWireup="false" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server"
Sub Button1_Click(s as Object, e as EventArgs)
MultiView1.SetActiveView(stepone)
End Sub

Sub Button2_Click(s as Object, e as EventArgs)
MultiView1.SetActiveView(StepTwo)
End Sub
Sub checkcountriesddl(ByVal s As Object, ByVal e As EventArgs)
If countriesddl.SelectedItem.Value = "CA" Or countriesddl.SelectedItem.Value = "US" Then
statesddl.Visible = True
Else
statesddl.Visible = False
End If

End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering=true />
<table><tr><td>
<asp:button ID="button1" runat=server Text="Step 1 Tab" onclick=Button1_click />
</td><td>
<asp:button ID="button2" runat=server Text="Step 2 Tab" onclick=Button2_click />
</td></tr></table>
<atlas:UpdatePanel runat=server ID=mvup>
<Triggers>
<atlas:ControlEventTrigger ControlID=button1 EventName="Click" />
<atlas:ControlEventTrigger ControlID=button2 EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:MultiView id="MultiView1" runat="server" ActiveViewIndex=0>

<asp:View id="stepone" runat="server" >
Hi there
</asp:View>
<asp:View ID="steptwo" runat="server">
<asp:Label ID="tobeupdated" runat=server Text="Welcome to Step Two" /><br /><br />
<asp:PlaceHolder ID="statesplaceholder" runat=server>
<asp:DropDownList ID="statesddl" runat=server>
<asp:ListItem Value="AK" Text="Alaska"></asp:ListItem>
<asp:ListItem Value="AR" Text="Arizona"></asp:ListItem>
</asp:DropDownList></asp:PlaceHolder><br /><br />
<asp:dropdownlist OnSelectedIndexChanged="checkcountriesddl" runat="server" id="countriesddl">
<asp:ListItem Value="US" Text="United States"></asp:ListItem>
<asp:ListItem Value="CA" Text="Canada"></asp:ListItem>
<asp:ListItem Value="FR" Text="France"></asp:ListItem>
</asp:dropdownlist>

</asp:View></asp:MultiView>
</ContentTemplate></atlas:UpdatePanel>

</form>
</body>
</html
I tried setting autopostback=true on the dropdownlist. No effect.

I tried adding a trigger to the multiview triggers:

<atlas:ControlEventTrigger ControlID=countriesddl EventName="SelectedIndexChanged" />

So then I tried another update panel (replacing the purple section above)

<atlas:updatepanel ID="statesup" runat=server>
<Triggers>
<atlas:ControlEventTrigger ControlID="countriesddl" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:PlaceHolder ID="statesplaceholder" runat=server>
<asp:DropDownList ID="statesddl" runat=server>
<asp:ListItem Value="AK" Text="Alaska"></asp:ListItem>
<asp:ListItem Value="AR" Text="Arizona"></asp:ListItem>
</asp:DropDownList></asp:PlaceHolder>
</ContentTemplate></atlas:updatepanel>
<br /><br />
<asp:dropdownlist AutoPostBack=true OnSelectedIndexChanged="checkcountriesddl" runat="server" id="countriesddl">
<asp:ListItem Value="US" Text="United States"></asp:ListItem>
<asp:ListItem Value="CA" Text="Canada"></asp:ListItem>
<asp:ListItem Value="FR" Text="France"></asp:ListItem>
</asp:dropdownlist>

Interesting that it doesn't work, but then if you click one of the buttons that controls the multiview, that it then fires the SelectedIndexChanged

Actually, I meant to hide the placeholder, not the DDL, but what I did is pretty much the same. sorry for the confusion
Hi !
I'm having the same problem while trying to have an atlas-updatable GridView inside an atlas-changeable Multiview. Basically it's the same thing : inclusion of updatepanels... no problem with the multiview alone, no problem if my gridview is outside, but when I put one in the other my gridview can't be updated. If I suppress the grid's updatepanel, any click on it sends me back to the main view of the multiview...

I'm not sure you managed to solve yours, did you ?

No comments:

Post a Comment