Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 586
  • Last Modified:

Trouble With Update Panels

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
JB4375
Asked:
JB4375
  • 6
  • 3
  • 2
  • +1
4 Solutions
 
Roopesh ReddyIT AnalystCommented:
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
 
Jerry MillerCommented:
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
 
JB4375Author Commented:
@RopeshReddy: Right, checkbox resets the TBReq items. The addition of the TBPhone was a mistake.

@JMiller: I'll give that a shot. Thanks!!
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
JB4375Author Commented:
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
 
Obadiah ChristopherCommented:
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
 
Jerry MillerCommented:
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
 
JB4375Author Commented:
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
 
Roopesh ReddyIT AnalystCommented:
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
 
Jerry MillerCommented:
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
 
JB4375Author Commented:
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
 
JB4375Author Commented:
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
 
JB4375Author Commented:
Thanks for the for the help everyone!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now