Javascript in FormView/NestedViewTemplate

2 posts, 0 answers
  1. Joachim
    Joachim avatar
    4 posts
    Member since:
    Apr 2009

    Posted 29 Apr 2009 Link to this post

    Hello Telerik-Team,

    I am new to using your controls and ran into the following problem:

    I am using a RadGrid with a NestedViewTemplate, into which I put a Formview to display details for each grid entry.
    The FormView contains several controls, checkboxes, dropdowns, textboxes, and  I need to check several dependencies between those controls using Javascript.

    How can I easily gain access to the controls in each FormView in this scenario? Do I need a special findControl-method?

    Hope you can help me, I am quite a bit confused atm.
  2. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 04 May 2009 Link to this post

    Joachim-

    Are you trying to access the controls in the FormView client-side with JavaScript? I'm assuming that's the case.

    There are a number of approaches you could take to access these controls via JavaScript after the page loads. It all depends on how you're doing your validation. One approach is to use jQuery's adavnced DOM search support to find the controls you need and then perform your validation from there. For example, using jQuery, I could look for a specific input control in my FormView like this when my textbox blur event fires:

    <asp:TextBox runat="server" onblur="handleTextBlur(this);" ... 
     
    function handleTextBlur(element) 
       var control = $(element).siblings("input[id*='div-comment-']"); 

    Using the "siblings" selector will limit my search to elements in the same container as my original element, and then using the "[id*= ]" syntax enables me to do a wildcard search for a control ID. Some combination of the jQuery search patterns should give you the control you need.

    Hope that helps!
    -Todd
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top