Solved

Controls Render Twice

Posted on 2008-10-21
7
738 Views
Last Modified: 2012-05-05
Hi

I am using an Update Panel but when I click the button within the  panel. It renders the controls (1 textbox and a dropd down) twice. Code is below.

Any ideas on what I am doing wrong....

Thansk
<asp:UpdatePanel ID="UpdatePanel2" runat="server">

			

			<ContentTemplate>

					<asp:Button ID="cmdUseThis" runat="server" Text="Use This" onclick="cmdUseThis_Click" />
 

				</td>

			</tr>
 

			<tr>

			

				<td class="rowLabel">

					&nbsp;State:</td>

				<td>

					&nbsp;

					<asp:TextBox ID="txtState" runat="server"></asp:TextBox>

				</td>

			</tr>

			<tr>

				<td class="rowLabel" valign="top">

					Country:</td>

				<td>

					&nbsp;

					<asp:DropDownList ID="ddlCountry" runat="server" AppendDataBoundItems="true">

					<asp:ListItem></asp:ListItem>

					</asp:DropDownList>	

					

					<asp:UpdateProgress ID="UpdateProgress1" runat="server">

				<ProgressTemplate>

				<img alt="working..." src="../images/spinner.gif" />

				</ProgressTemplate>

				</asp:UpdateProgress>

				</td></tr></table>

			</ContentTemplate>
 

			</asp:UpdatePanel>

Open in new window

0
Comment
Question by:patelajk
  • 4
  • 3
7 Comments
 
LVL 10

Expert Comment

by:jinn_hnnl
ID: 22766636
What do you mean by render it tiwce, you see 4 thing after the click, or you see the dropdown with duplicated data? Can you show us how your button click is defined  in code behind?


0
 

Author Comment

by:patelajk
ID: 22766676
button code is and yes i see 4 things 2 with the data which generate after the onclick the the same ones below but with no data

      Protected Sub cmdUseThis_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            If Not ddlCountry Is Nothing Then
                  ddlCountry.Items.Clear()
                  PopulateDropDowns()
            End If
            Dim objCountryID As Object = DataAccess.getScalarResult("SELECT City_Country_ID FROM tblCity WHERE City_ID = " & listLocInfo.SelectedValue)
            Dim objStateID As Object = DataAccess.getScalarResult("SELECT City_State_ID FROM tblCity WHERE City_ID = " & listLocInfo.SelectedValue)
      
            If Not IsDBNull(objStateID) Then
                  txtState.Text = DataAccess.getScalarResult("SELECT State_Name FROM tblState WHERE State_ID = " & objStateID)
            End If
            
            ddlCountry.Items.FindByValue(objCountryID).Selected = True
            ddlCountry.Visible = False
            txtState.Visible = False
            
      End Sub

0
 
LVL 10

Expert Comment

by:jinn_hnnl
ID: 22766805
Is this update panel part within an WebUserControl, if so, you might wanna check if you have added the entire thing twice (on PageLoad, PreReder ... once and another place two).

If not,
 PopulateDropDowns() ??? what does this function do??? <- the way I look at the name, I guess it add another dropdown to the container control.

Right click on the output browser and see if you see 4 different stuffs there, and try to run it in IE and Firefox to see if both browser acts the same way (I guess they do).

Hope this helps

JINN


0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:patelajk
ID: 22767362
PopulateDropDowns gets populate the drop down with values from a database - in this case the countries

i am not adding it twice i am pretty sure of that and IE does the same thing
0
 
LVL 10

Accepted Solution

by:
jinn_hnnl earned 125 total points
ID: 22767497
Ok here might be the problem, all what I can guess is the UpdatePanel screw up your page as you interpret them in between your table html tag. Which not wise able.

You might try to redecorate them abit by put the entire table content inside that updatePanel instead of open somewhere, start with a <td> and end table before closing the updatePanel

Can you give another try?

JINN


<asp:UpdatePanel ID="UpdatePanel2" runat="server">                        

         <ContentTemplate>

		<table>

			<tr>

				<td colspan="2">

                                        <asp:Button ID="cmdUseThis" runat="server" Text="Use This" onclick="cmdUseThis_Click" />

 

                                </td>

                        </tr>

 

                        <tr>

                        

                                <td class="rowLabel">

                                         State:

				 </td>

                                <td>                                         

                                        <asp:TextBox ID="txtState" runat="server"></asp:TextBox>

                                </td>

                        </tr>

                        <tr>

                                <td class="rowLabel" valign="top">

                                        Country:</td>

                                <td>

                                         

                                        <asp:DropDownList ID="ddlCountry" runat="server" AppendDataBoundItems="true">

                                        <asp:ListItem></asp:ListItem>

                                        </asp:DropDownList>     

                                        

                                        <asp:UpdateProgress ID="UpdateProgress1" runat="server">

                                <ProgressTemplate>

                                <img alt="working..." src="../images/spinner.gif" />

                                </ProgressTemplate>

                                </asp:UpdateProgress>

                                </td>

			</tr>

		</table>

	</ContentTemplate>
 

</asp:UpdatePanel>

Open in new window

0
 

Author Closing Comment

by:patelajk
ID: 31508232
Brilliant.... thanks a million
0
 
LVL 10

Expert Comment

by:jinn_hnnl
ID: 22767628
Glad to help ^^

JINN
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET e-commerce website 4 55
Paging GridView 7 48
c# LinkButton OnClientClick 2 34
C#  Radio button search for Date not DateTime 4 32
AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

919 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

14 Experts available now in Live!

Get 1:1 Help Now