Showing posts with label views. Show all posts
Showing posts with label views. Show all posts

Monday, March 26, 2012

MultiView inside UpdatePanel - Validators not working

Hi All,

I have a problem with a page I'm building at the moment. Basically it includes a multiview with a number of views, in which where there is a usercontrol that contains a number of text fields with custom validators.

Without an updatepanel around the multiview, all works fine. However, when I put an updatepanel around the multiview to prevent full page rendering on postback, the valdidators fail. I have included a very simplified example below to explain my point.

My ASPX Page:

1<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>23<%@dotnet.itags.org. Register src="http://pics.10026.com/?src=WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %>4<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">5<html xmlns="http://www.w3.org/1999/xhtml">6<head runat="server">7 <title>Untitled Page</title>8</head>9<body>10 <form id="form1" runat="server">11 <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />12 <br />13 <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline" UpdateMode="Always">14 <ContentTemplate>15 <asp:Button ID="Button1" runat="server" Text="View 1" OnClick="Button1_Click" CausesValidation="false" />16 <asp:Button ID="Button2" runat="server" Text="View 2" OnClick="Button2_Click" CausesValidation="false" />17 <asp:Button ID="Button3" runat="server" Text="View 3" OnClick="Button3_Click" CausesValidation="false" />18 <br />19 <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">20 <asp:View ID="View1" runat="server">21 <asp:Label ID="Label1" runat="server" Text="View 1"></asp:Label>22 <uc1:WebUserControl ID="WebUserControl1" runat="server" />23 </asp:View>24 <asp:View ID="View2" runat="server">25 <asp:Label ID="Label2" runat="server" Text="View 2"></asp:Label>26 <uc1:WebUserControl ID="WebUserControl2" runat="server" />27 </asp:View>28 <asp:View ID="View3" runat="server">29 <asp:Label ID="Label3" runat="server" Text="View 3"></asp:Label>30 <uc1:WebUserControl ID="WebUserControl3" runat="server" />31 </asp:View>32 </asp:MultiView>33 </ContentTemplate>34 </asp:UpdatePanel>35 </form>36</body>37</html>38
Code Behind:
1public partialclass _Default : System.Web.UI.Page {2protected void Page_Load(object sender, EventArgs e) {3 }4protected void Button1_Click(object sender, EventArgs e) {5this.MultiView1.ActiveViewIndex = 0;6 }7protected void Button2_Click(object sender, EventArgs e) {8this.MultiView1.ActiveViewIndex = 1;9 }10protected void Button3_Click(object sender, EventArgs e) {11this.MultiView1.ActiveViewIndex = 2;12 }13}
 The User Control:
 
1<%@dotnet.itags.org. Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs"2 Inherits="WebUserControl" %>34<script type="text/javascript">5 function v(sender, args) {6 var v1 = $get("<%=TextBox1.ClientID%>");7 alert(v1);8 }9</script>1011<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>12<asp:Button ID="Button1" runat="server" Text="Button" CausesValidation="true" />13<asp:CustomValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"14 Font-Bold="True" Font-Size="X-Large" Text="*" ClientValidationFunction="v" ValidateEmptyText="true" />15

Create the project and add the user control and the default.aspx page. Run it. Try the validator in the View1 (selected by default), it works fine, alerting an [object] to denote the field was found ok.

Switch to another view and all you get alerted is [null] showing the control was not found.

Can anyone get this code to work with the updatepanel?

Andy.

Hi;

Hi;

I had this problem with Ajax Asp.NET Beta 2;
So.. this is a bug, and it was fixed on Features November CTP

http://go.microsoft.com/fwlink/?LinkID=77294

You need download, install and configure the the web.config;
Join it;

[]'s

I was sure I was using the Nov issue. I will check...

Andy.

multiview refresh inside updatepanel

i've a gridview based on the dropdownlist and multiview with two views based on the gridview selection.

when i change selection in my dropdownlist without click on my gridview, the information in the multiview in view1 and view2 is refreshed, but once i change the selection in my gridview the refresh happend only in the active view not in the other.

help me please

S.O.S ...Sos...sos...helpConfused


thanks to all for your reply!!!Wink.

i've found the solution it's working but i'm sure there is an other way and better.

when i change the selection in the gridview i refresh the sql connection.

and when i set the view1 or view2 to active i refresh the connection too.

gridveiw1.datasourceid="sqlconnectin1".

Multiview, modalPopup, updatepanel, popupcontrolextender

Hello,

I have a multiview that contains six views. Two of the views have update panels on them. I had it working with a popupcontrolextender (for a calender) and using updatepanel to move between the views without postback.

However, I added modalPopup to one of my views and now it doesn't switch between the views anymore. If I take the modalPopup out, it works again.

Has anyone run into this before? If so, how did you get around it?

Check the JavaScript debugger window for script errors, maybe?