views:

92

answers:

3

i have a user control that i made, and i place two instances of that control on the same page... when i interact with the first control, it updates the elements (using ajax) of the first userControl, as it should. but when i do the same thing with the second userControl, it updates the elements on the first userControl as opposed to itself!!! this is really strange as nothing is declared as shared, and it looks like an instantiation problem.

each userControl is wrapped around its own ajax updatepanel.

any ideas anyone? is this a common pitfall?

this is the structure of my code

<@ Control Language="VB" ClassName="AgeRange">
<@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxCT">

<script runat="server">

Delegate Sub NumberClickedEventHandler(ByVal sender As Object, ByVal e As EventArgs)
Public Event NumberClicked As NumberClickedEventHandler

Public Class NumberClickedEventArgs
          ' EVENT ARGS CLASS

End Class


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
         ' PAGE LOAD STUFF HERE

End Sub

Public Property A FEW PROPERTIES HERE

Protected Function GetHTML(ByRef lastNumber As Byte, Optional ByVal FromNo As Byte = 18,
            Optional ByVal bForPopDown As Boolean = False, Optional ByVal bForPopUp As Boolean = False) As String

        SOME CODE HERE
End Sub

--

<asp:UpdatePanel ID="upAgeRange" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional" ClientIDMode="Static"
<ContentTemplate>
    <table><tr>
        <td>

            <span id="spanPopUp" runat="server">
            </span>
            <div id="dPanel" runat="server">
            </div>
            <span id="spanPopDown" runat="server">
            </span>
        </td>
    </tr>
    </table>

    <AjaxCT:HoverMenuExtender ID="hmeUp" runat="server" TargetControlID="dPanel" PopupControlID="spanPopUp" OffsetY="-200">
    </AjaxCT:HoverMenuExtender>

    <AjaxCT:HoverMenuExtender ID="hmeDown" runat="server" TargetControlID="dPanel" PopupControlID="spanPopDown" OffsetY="60">
    </AjaxCT:HoverMenuExtender>
</ContentTemplate>
</asp:UpdatePanel>
A: 

Assuming this is a Client Side issue and not Server Side.

You'll need to ensure that both controls have unique names.

My preference is to places these controls in a <div> that has a unique class name.

<div class="Ctrl1"> and <div class="ctrl2">

I can then use findControl within the actual class I'm interested in.

Something like $('.Ctrl2').findControl....

griegs
This is using client-side JavaScript with jQuery. I believe the original poster's problem was using server-side code with the ASP.NET UpdatePanel.
Eilon
You may be right but I took it to mean that on the return of the AJAX call the poster was attempting to update a control client side.
griegs
Ah good point. I think we need some more information about the scenario such as code samples and the structure of the page.
Eilon
i am doing all the updating on the server side... really strange, i fugred asp.net created totally seperate instances of all contained objects in a userControl
Erx_VB.NExT.Coder
also, i updated/edited my orig posting with more information on page code structureit could be this that i am calling a updatePanel using a static name, ... function SubmitAge(age) { $get('HiddenAge').value = age; __doPostBack('upAgeRange'); }
Erx_VB.NExT.Coder
can i just put '<%= upAgeRange.ClientID %>' instead of 'upAgeRange' ?
Erx_VB.NExT.Coder
That would certainly give you the unique name of the control yeah and I suspect that that might be part of the problem. Seem's you're using the asp.net-mvc framework yes? @Eilon removed the mvc tag from your question which you may want to add back in.
griegs
nope, just aspx really... still getting a problem calling the function at teh onclick="SubmitAge(66, 'ctl00_MainContent_arTo_upAgeRange')" part .... put the js function in a js file, seems you really cant write functions directly in user controls otherwise the function will be printed twice in teh same page... (awch, thats painful to even think about)
Erx_VB.NExT.Coder
A: 

You are currently using ClientIDMode="Static" in your update panel control. This means that the generated HTML will have duplicated IDs. The auto-generated client-side code for the update panels needs to have distinct IDs so that it can find the correct HTML elements in which to place updates.

You probably don't need that ClientIDMode="Static" at all.

Jacob
A: 

turns out it was my fault, itnernal logic reason/issue, thanks

Erx_VB.NExT.Coder