Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...jQuery - how to define control idjQuery - how to define control id
Previous
 
Next
New Post
9/27/2009 4:56 AM
 

Hi All, 

Newbie here having some problems with jQuery..    I created a very simple module with only 5 textbox for testing.. in the page load function I have added

jQuery.RequestRegistration()


Dim script As String = String.format(glbScriptformat, ResolveUrl("ViewAccMgr.js"))
DotNetNuke.UI.Utilities.ClientAPI.RegisterClientScriptBlock(Page, "ViewAccMgr_js", script)

 In the js script file i have the following in the document ready function.   I know that jQuery is working because the function with the control id = ("#dnn_ctr377_ViewAccMgr_txtSearchTerm") works,  but the ("#txtSearchTerm") does not.  However, is it a pratical way to write the jQuery since i will never know the ctr-id.. etc and which page the module is used in...

    jQuery("#dnn_ctr377_ViewAccMgr_txtSearchTerm").focus(
        function() {
            Hello2");
        }
    );

    jQuery("#txtSearchTerm").focus(
        function() {
            Hello3");
        }
    );

 
New Post
9/27/2009 2:19 PM
 

You'll need to use "CONTROLNAME.ClientID" to get the client ID for use in javascript. 

There are different ways to do this, I create a structure in JS to hold all the clientIDs I'll be needing. You could put the values in labels, ect.

In some fashion, get the ClientId from server to client, then you can use it. :)

 
New Post
9/28/2009 11:15 AM
 

Hi Baatezu,

thanks for the reply, so from what i can understand, the script will have to get the client control id in the server side and pass back down.  In this case i would have to some how find, or deduce the control id in the page load function and replace it before i register the script block..

eg...

jQuery.RequestRegistration()
Dim script As String = String.format(glbScriptformat, ResolveUrl("ViewAccMgr.js"))
script.replace("txtSearchTerm","the appropriate name")
DotNetNuke.UI.Utilities.ClientAPI.RegisterClientScriptBlock(Page, "ViewAccMgr_js", script)

correct??

 
New Post
9/28/2009 1:01 PM
Accepted Answer 

Yea, that looks like it would do it. I use a different method, but if you do

script.replace("txtSearchTerm", txtSearchTerm.ClientID)

it should replace with the ID that is on the client side.

 
New Post
9/30/2009 1:37 AM
 

Hi Baatezu,

Thanks for the help.. the ClientID pointed me to the right direction, and i see the light now :)

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...jQuery - how to define control idjQuery - how to define control id


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out