Solved

Trouble With Update Panels

Posted on 2013-01-19
12
544 Views
Last Modified: 2013-01-24
I started experimenting with update panels after getting tired of seeing my entire page flash everytime there was a postback.

The way the form works:
1. User selects their UserID from a drop down which is bound to a table. First name, and Last name fields are populated. (working)
2. If the user ID isn't present they select 'unknown' and a second row appears for them to enter the info manually. (working)
3. If the requestor is entering the data for themself, they can check a box to replicate the info from above into that section of the form. (working)

In the event that someone goes back up to the top and changes the dropdown entry, I want the above sections of the form to reset. Everything does EXCEPT for the Phone, Dept. Building/Floor textboxes.

Any attempt at increasing one of the update panels to include these fields, or to create a separate panel around them results in the error: "An extender can't be in a different UpdatePanel than the control it extends." Which is about as useless/non-fromative as it gets IMHO.

Thanks,


JB

    <div id="content">

         <div class="container">                
            <asp:Label ID="Label99" class="BiggerLblSub" runat="server" Text="User Information"></asp:Label>
         </div><!-- end # container -->
        <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Always">
           <ContentTemplate>
               <div class="container">
                 <div class="firstcol">
                    <asp:Label ID="Label7" runat="server" Font-Size="Smaller" ForeColor="Red" Text="*"></asp:Label>
                    <asp:Label ID="Label8" runat="server" Text="User ID: "></asp:Label>
                    <asp:DropDownList ID="DDLUserID" AppendDataBoundItems="true" AutoPostBack="true"
                         runat="server" TabIndex="-1" DataSourceID="SqlDataSource1" DataTextField="Remedy_Login_ID"
                         DataValueField="Remedy_Login_ID" OnSelectedIndexChanged="DDLUserID_SelectedIndexChanged"
                         Width="160px">
                         <asp:ListItem Text="Select User ID" Value="" />
                    </asp:DropDownList>
                </div><!-- end # firstcol -->
                <div class="secondcol">
                    <asp:Label ID="Label10" runat="server" Font-Size="Smaller" ForeColor="Red" Text="*"></asp:Label>
                    <asp:Label ID="Label11" runat="server" Text="First Name: "></asp:Label>
                    <asp:TextBox ID="TBFirstName" TabIndex="-1" runat="server" MaxLength="20"></asp:TextBox>
                </div><!-- end # secondcol -->
                <div class="thirdcol">
                    <asp:Label ID="Label12" runat="server" Font-Size="Smaller" ForeColor="Red" Text="*"></asp:Label>
                    <asp:Label ID="Label13" runat="server" Text="Last Name: "></asp:Label>
                    <asp:TextBox ID="TBLastName" TabIndex="-1" runat="server" MaxLength="25"></asp:TextBox>
                </div><!-- end # thirdcol -->
                <div class="fourthcol">
                </div><!-- end # fourthcol -->
              </div><!-- end # container -->

                 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                     <div class="container">
                         <asp:Image ID="Arrow" runat="server" ImageUrl="~/images/redrightarrow.jpg" />
                        <%--<asp:Label ID="Label89" runat="server" Font-Size="Smaller" ForeColor="red" Text="*"></asp:Label>--%>
                        <asp:Label ID="Label90" runat="server" Font-Size="Small" BackColor="white" Text="Your User ID wasn't listed in Remedy. Please enter your User ID and Name below."></asp:Label><br /><br />
                        <div class="firstcol">
                            <asp:Label ID="Label91" runat="server" Font-Size="Smaller" ForeColor="Red" Text="*"></asp:Label>
                            <asp:Label ID="Label94" runat="server" Text="User ID: " ></asp:Label>
                            <asp:TextBox ID="TBUName" tabindex="1" runat="server" maxlength="20"></asp:TextBox>
                            <cc1:FilteredTextBoxExtender TargetControlID="TBUName" FilterType="Custom,LowercaseLetters" ValidChars="- " ID="FTBE56" runat="server"></cc1:FilteredTextBoxExtender>
                        </div><!-- end # firstcol -->
               
                        <div class="secondcol">
                            <asp:Label ID="Label95" runat="server" Font-Size="Smaller" ForeColor="Red" Text="*"></asp:Label>
                            <asp:Label ID="Label96" runat="server" Text="First Name: " ></asp:Label>
                            <asp:TextBox ID="TBUFN" tabindex="1" runat="server" maxlength="20"></asp:TextBox>
                            <cc1:FilteredTextBoxExtender TargetControlID="TBUFN" FilterType="Custom,UppercaseLetters,LowercaseLetters" ValidChars="- " ID="FTBE57" runat="server"></cc1:FilteredTextBoxExtender>
                        </div><!-- end # secondcol -->
               
                        <div class="thirdcol">
                            <asp:Label ID="Label97" runat="server" Font-Size="Smaller" ForeColor="Red" Text="*"></asp:Label>
                            <asp:Label ID="Label98" runat="server" Text="Last Name: "></asp:Label>
                            <asp:TextBox ID="TBULN" tabindex="1" runat="server" maxlength="25"></asp:TextBox>
                            <cc1:FilteredTextBoxExtender TargetControlID="TBULN" FilterType="Custom,UppercaseLetters,LowercaseLetters" ValidChars="- " ID="FTBE58" runat="server"></cc1:FilteredTextBoxExtender>
                        </div><!-- end # thirdcol -->
                        <div class="fourthcol">
                        </div><!-- end # fourthcol -->
                    </div><!-- end # container -->
                    </ContentTemplate>
                 </asp:UpdatePanel>
                </ContentTemplate>
              <Triggers>
                 <asp:AsyncPostBackTrigger ControlID="DDLUserID" />
              </Triggers>
        </asp:UpdatePanel>

<%--        <asp:UpdatePanel ID="UpdatePanel4" runat="server">
           <ContentTemplate>--%>
            <div class="container">
                <div class="firstcol">
                    <asp:Label ID="Label14" runat="server" Font-Size="Smaller" ForeColor="Red" Text="*"></asp:Label>
                    <asp:Label ID="Label15" runat="server" Text="Phone: "></asp:Label>
                    <asp:TextBox ID="TBPhone" runat="server" TabIndex="1" MaxLength="13"></asp:TextBox>
                </div>
                <!-- end # firstcol -->
                <div class="secondcol">
                    <asp:Label ID="Label18" runat="server" Font-Size="Smaller" ForeColor="Red" Text="*"></asp:Label>
                    <asp:Label ID="Label128" runat="server" Text="Department: "></asp:Label>
                    <asp:TextBox ID="TBDept" runat="server" TabIndex="2" MaxLength="30"></asp:TextBox>
                </div>
                <!-- end # secondcol -->
                <div class="thirdcol">
                    <asp:Label ID="Label129" runat="server" Font-Size="Smaller" ForeColor="Red" Text="*"></asp:Label>
                    <asp:Label ID="Label130" runat="server" Text="Building/Floor "></asp:Label>
                    <asp:TextBox ID="TBLocation" runat="server" TabIndex="3" MaxLength="30"></asp:TextBox>
                </div>
                <!-- end # thirdcol -->
                <div class="fourthcol">
                </div><!-- end # fourthcol -->
            </div><!-- end # container -->
<%--          </ContentTemplate>
        </asp:UpdatePanel>--%>

            <div class="container">                
               <asp:Label ID="Label101" class="BigLblSub" runat="server" Text="Requestor Info"></asp:Label>
            </div><!-- end # container -->  

               <asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Always" runat="server">
                <ContentTemplate>
                <div class="container">
                    <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="true" />
                    <asp:Label ID="Label109" runat="server" Text="(Check Here If Same As Above)" Font-Size="Smaller"></asp:Label><br /><br />
                <div class="firstcol">
                    <asp:Label ID="Label102" runat="server" Font-Size="Smaller" ForeColor="Red" Text="*"></asp:Label>
                    <asp:Label ID="Label103" runat="server" Text="First Name: " ></asp:Label><br />
                    <asp:TextBox ID="TBReqFN" tabindex="8" runat="server" maxlength="20"></asp:TextBox>
                    <cc1:FilteredTextBoxExtender TargetControlID="TBReqFN" FilterType="Custom,UpperCaseLetters,LowercaseLetters" ValidChars="- " ID="FilteredTextBoxExtender1" runat="server"></cc1:FilteredTextBoxExtender>
                </div><!-- end # firstcol -->
                <div class="secondcol">
                    <asp:Label ID="Label107" runat="server" Font-Size="Smaller" ForeColor="Red" Text="*"></asp:Label>
                    <asp:Label ID="Label108" runat="server" Text="Last Name: " ></asp:Label>
                    <asp:TextBox ID="TBReqLN" tabindex="9" runat="server" maxlength="20"></asp:TextBox>
                    <cc1:FilteredTextBoxExtender TargetControlID="TBReqLN" FilterType="Custom,UppercaseLetters,LowercaseLetters" ValidChars="- " ID="FilteredTextBoxExtender3" runat="server"></cc1:FilteredTextBoxExtender>
                </div><!-- end # secondcol -->                
                <div class="thirdcol">
                    <asp:Label ID="Label104" runat="server" Font-Size="Smaller" ForeColor="Red" Text="*"></asp:Label>
                    <asp:Label ID="Label105" runat="server" Text="Phone Number: " ></asp:Label>
                    <asp:TextBox ID="TBReqPhone" tabindex="10" runat="server" maxlength="20"></asp:TextBox>
                    <cc1:FilteredTextBoxExtender TargetControlID="TBReqPhone" FilterType="Custom,Numbers" ValidChars="- ()" ID="FilteredTextBoxExtender2" runat="server"></cc1:FilteredTextBoxExtender>
                </div><!-- end # thirdcol -->
                <div class="fourthcol">
                </div><!-- end # fourthcol -->
              </div><!-- end # container -->
                </ContentTemplate>
                    <Triggers>
                       <asp:AsyncPostBackTrigger ControlID="CheckBox2" />
                    </Triggers>
               </asp:UpdatePanel>  


***VB Backend****

 Protected Sub DDLUserID_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DDLUserID.SelectedIndexChanged
        CheckBox2.Checked = False
        TBReqFN.Text = ""
        TBReqLN.Text = ""
        TBReqPhone.Text = ""
        TBPhone.Text = ""
        If DDLUserID.SelectedIndex = 0 Then
            TBFirstName.Text = ""
            TBLastName.Text = ""
            TBPhone.Text = ""
            TBDept.Text = ""
            TBLocation.Text = ""
            TBUName.Text = ""
            TBUFN.Text = ""
            TBULN.Text = ""
            CheckBox2.Checked = False
            TBReqFN.Text = ""
            TBReqLN.Text = ""
            TBReqPhone.Text = ""
        Else
            intcount = 0
            Dim sConn As Data.SqlClient.SqlConnection
            Dim sComm As Data.SqlClient.SqlCommand
            Dim sAdapt As Data.SqlClient.SqlDataAdapter

            sConn = New Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("MyConnection2").ConnectionString)
            sComm = New Data.SqlClient.SqlCommand("SELECT Last_Name, First_Name From Table WHERE ID = '" & DDLUserID.SelectedItem.Text & "'", sConn)
            sAdapt = New Data.SqlClient.SqlDataAdapter(sComm)
            sConn.Open()

            Dim r As Data.SqlClient.SqlDataReader = sComm.ExecuteReader()
            While r.Read()
                Dim strFN As String = CStr(r("First_Name"))
                TBFirstName.Text = strFN
                Dim strLN As String = CStr(r("Last_Name"))
                TBLastName.Text = strLN
            End While
            r.Close()
        End If
        If DDLUserID.SelectedItem.Text = "unknown" Then
            UpdatePanel1.Visible = True
            CheckBox2.Checked = False
            TBPhone.Text = ""
            TBDept.Text = ""
            TBLocation.Text = ""
            TBReqFN.Text = ""
            TBReqLN.Text = ""
            TBReqPhone.Text = ""
        Else
            UpdatePanel1.Visible = False
            TBUName.Text = ""
            TBUFN.Text = ""
            TBULN.Text = ""
        End If
    End Sub
0
Comment
Question by:JB4375
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 23

Expert Comment

by:Roopesh Reddy
ID: 38798222
Hi,

I see that you are not resetting the values on OnSelectedIndexChanged event!

Seems like, you have missed clearing the following two text fields

 TBDept.Text = ""
 TBLocation.Text = ""

Open in new window


Try with this code -

Protected Sub DDLUserID_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DDLUserID.SelectedIndexChanged
        CheckBox2.Checked = False
        TBReqFN.Text = ""
        TBReqLN.Text = ""
        TBReqPhone.Text = ""
        TBPhone.Text = ""
        TBDept.Text = ""
        TBLocation.Text = ""
        If DDLUserID.SelectedIndex = 0 Then
            TBFirstName.Text = ""
            TBLastName.Text = ""
            TBPhone.Text = ""
            TBDept.Text = ""
            TBLocation.Text = ""
            TBUName.Text = ""
            TBUFN.Text = ""
            TBULN.Text = ""
            CheckBox2.Checked = False
            TBReqFN.Text = ""
            TBReqLN.Text = ""
            TBReqPhone.Text = ""
        Else
            intcount = 0
            Dim sConn As Data.SqlClient.SqlConnection
            Dim sComm As Data.SqlClient.SqlCommand
            Dim sAdapt As Data.SqlClient.SqlDataAdapter

            sConn = New Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("MyConnection2").ConnectionString)
            sComm = New Data.SqlClient.SqlCommand("SELECT Last_Name, First_Name From Table WHERE ID = '" & DDLUserID.SelectedItem.Text & "'", sConn)
            sAdapt = New Data.SqlClient.SqlDataAdapter(sComm)
            sConn.Open()

            Dim r As Data.SqlClient.SqlDataReader = sComm.ExecuteReader()
            While r.Read()
                Dim strFN As String = CStr(r("First_Name"))
                TBFirstName.Text = strFN
                Dim strLN As String = CStr(r("Last_Name"))
                TBLastName.Text = strLN
            End While
            r.Close()
        End If
        If DDLUserID.SelectedItem.Text = "unknown" Then
            UpdatePanel1.Visible = True
            CheckBox2.Checked = False
            TBPhone.Text = ""
            TBDept.Text = ""
            TBLocation.Text = ""
            TBReqFN.Text = ""
            TBReqLN.Text = ""
            TBReqPhone.Text = ""
        Else
            UpdatePanel1.Visible = False
            TBUName.Text = ""
            TBUFN.Text = ""
            TBULN.Text = ""
        End If
    End Sub

Open in new window


Hope it helps u...
0
 
LVL 18

Assisted Solution

by:Jerry Miller
Jerry Miller earned 300 total points
ID: 38798652
The Phone, Dept. Building/Floor textboxes aren't actually in an update panel. You have that panel commented out. Try using only one update panel around the entire section as a test instead of three panels.
0
 
LVL 1

Author Comment

by:JB4375
ID: 38799608
@RopeshReddy: Right, checkbox resets the TBReq items. The addition of the TBPhone was a mistake.

@JMiller: I'll give that a shot. Thanks!!
0
 
LVL 1

Author Comment

by:JB4375
ID: 38799672
JMiller,

I've done as you suggested and removed all of the update panels except the one at top, and closed it off at the bottom below the requesor info.

I've tried it with and without the triggers, and I'm still getting the original error message: "An extender can't be in a different UpdatePanel than the control it extends."

I'm really not even sure what this is supposed to indicate.
0
 
LVL 20

Assisted Solution

by:informaniac
informaniac earned 100 total points
ID: 38799824
I feel the issue is due to the FilteredTextBoxExtender controls. Try to remove all of them and check if it is causing the issue.

Do you have an updatepanel inside an updatepanel and inside that updatepanel you are having the FilteredTextBoxExtender control.
0
 
LVL 18

Accepted Solution

by:
Jerry Miller earned 300 total points
ID: 38803349
The error is telling you that one of the extenders is in a different update panel than the control (textbox, label, etc) it is trying to extend. But I don't see that in the code the you have posted. Like informaniac stated, remove the extenders and then add them back one at a time.

Sometimes errors like that indicate a missing character in the code. It could be a tag missing its end tag.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:JB4375
ID: 38809896
I currently I just have one update panel for the form and the error occurs.

Interesting that I could get away with a nested update panel for one section, AND a separate update panel for a different section with no errors before. LOL.

I was afraid that's what the extender error was about, but isn't that exactly the reason for each extender having a unique ID that points specifically to the item it controls?

I'll test each of the extenders to see what it yields.

Thanks,

JB
0
 
LVL 23

Assisted Solution

by:Roopesh Reddy
Roopesh Reddy earned 100 total points
ID: 38810258
Hi,

I suggest you to remove all the UpdatePanel's and the extender controls and start integrating one by one and check whether you get the problem again!

This way you can easily track down the issue!

Hope it helps u...
0
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 38812260
Have you tried to do Clean Solution since the error started? Now that you have only the one updatePanel, go to Solution Explorer, right click and choose Clean Solution. This may get rid of the error since obviously the code shoudn't be displaying that error.

I have seen some of these oddities only go away with creating a new page and copying the same code into it.
0
 
LVL 1

Author Comment

by:JB4375
ID: 38812298
JMiller,

I hadn't, and wasn't familiar with that option. I Googled, and found that it's because I'm running it as a web site, as opposed to a web app.

I performed a rebuild instead, which I've done many times through the process. No errors, until I attempt to "View In Browser".

Having said that, I've had too many other pressing issues to allow me to look at this today. I'll try to find some time tonight.

Thanks,

JB
0
 
LVL 1

Author Comment

by:JB4375
ID: 38814894
OK... so the problem resulted from a couple of textbox extenders that were out of place. Once this change was made I was able to put the update panels in place where I had them before. So I'm back to square one on the intial issue.

To reiterate: In the event that someone goes back up to the top and changes the dropdown entry, I want the above sections of the form to reset. Everything does EXCEPT for the Phone, Dept. Building/Floor textboxes.

I've noticed that if I select my userID and fill in all my info, the go back up and change the dropdown to 'unknown' or vice-versa everything works. It also works if go change it back to 'Select User ID'

It's only when I select a user ID, and then change to another userID that the Phone, Dept. Building/Floor textboxes don't clear out.

Resolution - Within DDLUserID_SelectedIndexChanged section on the VB page I called a subroutine to reset the values in those textboxes after it fills in the First and Last names associated with the UserID. It's not pretty, but it fires everytime.

Example:

            Dim r As Data.SqlClient.SqlDataReader = sComm.ExecuteReader()
            While r.Read()
                Dim strFN As String = CStr(r("First_Name"))
                TBFirstName.Text = strFN
                Dim strLN As String = CStr(r("Last_Name"))
                TBLastName.Text = strLN
            End While
            r.Close()
            Call Partial_Clear()  
        End If

    Public Sub Partial_Clear()
        TBPhone.Text = ""
        TBDept.Text = ""
        TBLocation.Text = ""
        TBUName.Text = ""
        TBUFN.Text = ""
        TBULN.Text = ""
        CheckBox2.Checked = False
        TBReqFN.Text = ""
        TBReqLN.Text = ""
        TBReqPhone.Text = ""
    End Sub
0
 
LVL 1

Author Closing Comment

by:JB4375
ID: 38814930
Thanks for the for the help everyone!!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Log4Net custom Appender not being fired. 5 44
System32Int Error 8 44
Form design in vb.net 7 20
Asp.net mvc 5 5 20
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now