I've a Problem in ajax update panel??

Last post 02-15-2008 5:41 AM by tortuga. 5 replies.

Sort Posts:

  • I've a Problem in ajax update panel??

    02-14-2008, 2:26 AM
    • Member
      165 point Member
    • jack007
    • Member since 12-19-2007, 6:22 AM
    • Posts 588

    hello everyone,

    i m using vwd2005 express 

    i have a webform to register user.

    all the controls have required field validators.

    to organise the form i have created update panel

    and put some of the the server controls on it.

    within update panel there is edit button .

    when edit button is clicked the controls on it becomes enabled to make changes on it.

    now when i fill the correct values in all the server controls outside the update panel and 

    then click the edit button inside the edit panel,the panel is editable.no problem. 

    But whenever i click the edit button without first filling up the controls outside the panel ,the controls on the update panel doesnot get editable.

    required field validator error msg shows next to each control here. 

    i dont know whats the problem.

    ajax update panel was supposed to be for the partial postback right.? and i hope the controls on it is independent with

    the controls outside of it right? 

    but i dont know when ever i click the button inside the update panel the whole page seems to be refreshed.

    any clue how to use button inside the update panel without refreshing the whole page.?

    and if i need to use nested update panel where each panel is indepent of the other then how can i use it.?

    any links to good resources on this with example? 

    thanks.

    jack. 

     

      

  • Re: I've a Problem in ajax update panel??

    02-14-2008, 6:42 AM
    • Participant
      1,390 point Participant
    • Sam.Dev
    • Member since 12-12-2006, 10:54 AM
    • Lahore,Pakistan
    • Posts 342

    post ur code.

    but try to put as minimal code as u want s that i can easily understand it n can help u

    sam

    Saima Ghumman
    --Mark the post as Answer if the Post helps you--
  • Re: I've a Problem in ajax update panel??

    02-15-2008, 1:24 AM
    • Member
      165 point Member
    • jack007
    • Member since 12-19-2007, 6:22 AM
    • Posts 588

    Hi,

    can u just show me with simple eg: how nested update panel works where each update panel is independent other.

    i m not familiar with ajax update panel.

    i just need the basics how its work.

    thanks.

    jack. 

     

  • Re: I've a Problem in ajax update panel??

    02-15-2008, 1:34 AM
    • Participant
      1,390 point Participant
    • Sam.Dev
    • Member since 12-12-2006, 10:54 AM
    • Lahore,Pakistan
    • Posts 342

    here is a simple running example of popup extander

    try this one then movve to multiple updatepanels

    <div>

    <asp:Button ID="Button" runat="server" Text="Button" />

    </div>

    <ajaxtoolkit:modalpopupextender id="pop" runat="server" cancelcontrolid="btnCancel"

    enabled="True" popupcontrolid="Panel1" targetcontrolid="Button"></ajaxtoolkit:modalpopupextender>

    <asp:UpdatePanel runat="server" ID="update" UpdateMode="Conditional">

    <ContentTemplate>

    <asp:Panel ID="Panel1" runat="server" BorderColor="blue" BorderWidth="10px" Height="50px"

    Width="203px">

    <asp:DropDownList ID="DropDownList3" runat="server" OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged" AutoPostBack="True">

     

    </asp:DropDownList><br />

    <br />

    <asp:Button ID="btnCancel" runat="server" Text="Cancel" />

    </asp:Panel>

    </ContentTemplate>

    <Triggers>

    <asp:AsyncPostBackTrigger ControlID="Button" EventName="Click" />

    </Triggers>

    </asp:UpdatePanel>

    Saima Ghumman
    --Mark the post as Answer if the Post helps you--
  • Re: I've a Problem in ajax update panel??

    02-15-2008, 4:16 AM
    • Member
      165 point Member
    • jack007
    • Member since 12-19-2007, 6:22 AM
    • Posts 588

    HI SAM,

    i could not get ur example.

    i have posted my scenario here.may be u can help me out here.
     

    .aspx

     <%@ Page Language="C#" AutoEventWireup="true" CodeFile="qqq.aspx.cs" Inherits="qqq" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <h3>
                &nbsp;<span style="text-decoration: underline">USER REGISTRATION FORM</span></h3>
            <h3>
                <span style="text-decoration: underline">
                    <br />
                    <asp:ScriptManager ID="ScriptManager1" runat="server">
                    </asp:ScriptManager>
                </span>&nbsp;</h3>
        
        </div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            phone:<asp:TextBox ID="TextBox1" runat="server" Enabled="False"></asp:TextBox><asp:Button
                                ID="Button1" runat="server" Enabled="False" Text="add" />&nbsp;<br />
                            <br />
                            <asp:ListBox ID="ListBox1" runat="server" Enabled="False" Width="246px"></asp:ListBox>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                    <br />
                    <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                    email: &nbsp;&nbsp;
                            <asp:TextBox ID="TextBox2" runat="server" Enabled="False"></asp:TextBox><asp:Button
                                ID="Button6" runat="server" Enabled="False" Text="add" /><br />
                            <br />
                            <asp:ListBox ID="ListBox2" runat="server" Enabled="False" Width="244px"></asp:ListBox>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                    <br />
                    city: &nbsp; &nbsp; &nbsp;<asp:TextBox ID="TextBox7" runat="server" Enabled="False"></asp:TextBox><br />
                    <br />
                    address:<asp:TextBox ID="TextBox3" runat="server" Enabled="False"></asp:TextBox><br />
                    <br />
                    <br />
                    &nbsp;<asp:Button ID="Button3" runat="server" Text="edit" OnClick="Button3_Click" />
                    <asp:Button ID="Button2" runat="server" Text="savechange" /><br />
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
                    <br />
                    &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
                    <br />
                    <br />
                    &nbsp; &nbsp;
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="Button3" />
                </Triggers>
            </asp:UpdatePanel>
            <br />
            country:<asp:DropDownList ID="DropDownList1" runat="server">
                <asp:ListItem>USA</asp:ListItem>
                <asp:ListItem>CANADA</asp:ListItem>
            </asp:DropDownList>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="DropDownList1"></asp:RequiredFieldValidator><br />
            <br />
            name: &nbsp;&nbsp;
            <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox4"></asp:RequiredFieldValidator><br />
            <br />
            age: &nbsp; &nbsp; &nbsp;
            <asp:TextBox ID="TextBox5" runat="server" Width="46px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox5"></asp:RequiredFieldValidator><br />
            <br />
            dob: &nbsp; &nbsp;&nbsp;
            <asp:TextBox ID="TextBox6" runat="server" Width="89px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox6"></asp:RequiredFieldValidator><br />
            <br />
            <asp:Button ID="Button4" runat="server" Text="save form" />
            <asp:Button ID="Button5" runat="server" Text="cancel" />&nbsp;<br />
        </form>
    </body>
    </html>

    .cs

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class qqq : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            TextBox1.Enabled = true;
            TextBox2.Enabled = true;
            TextBox3.Enabled = true;
            TextBox7.Enabled = true;
            ListBox1.Enabled = true;
            ListBox2.Enabled = true;
            Button1.Enabled = true;
            Button6.Enabled = true;
            Button3.Enabled = false;

        }
    }
     

     

    the above code explains my scenario.

    here there is 2 update panels inside the parent update panel.

    there are controls inside the 2 update panels and outside them too(ie 3rth update panel)

    here i want to child update panels to work indepently of each other.i've made enable to false to

    all the controls.now when i click edit button

    inside the parent update control i want each controls in the form to get enabled.

    finally when save form is clicked i want all the form values get

    added to the database.

    my only problem is the use of update panel.

    My problem is when i click the edit button inside the parent control the required field error msg is displaying

    instead of making the update panels editable.

    any clue to overcome this.

    thanks.

    jack. 

       

     

  • Re: I've a Problem in ajax update panel??

    02-15-2008, 5:41 AM
    Answer
    • Member
      91 point Member
    • tortuga
    • Member since 02-15-2008, 5:31 AM
    • Posts 45

    Hi Jack,

     Not sure if I'm right, but here goes.


                    address:<asp:TextBox ID="TextBox3" runat="server" Enabled="False"></asp:TextBox><br />
                    <br />
                    <br />
                    &nbsp;<asp:Button ID="Button3" runat="server" Text="edit" OnClick="Button3_Click" />
                    <asp:Button ID="Button2" runat="server" Text="savechange" /><br />
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
                    <br />
                    &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
                    <br />
                    <br />
                    &nbsp; &nbsp;
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="Button3" />
                </Triggers>
            </asp:UpdatePanel>

     Aren't you putting the chicken before the egg when you have a trigger tag pointing to a button inside the update panel that you want to refresh. I'm having loads of trouble with the whole update panel so I'm sorry if this is not right, but I was under the impression that triggers should refer to controls outside of the update panel. Maybe you could move button 3 outside the update panel and give it a try.

     Hope it helps,

     turtuga

     

Page 1 of 1 (6 items)