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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0set label text with javascript in DNN moduleset label text with javascript in DNN module
Previous
 
Next
New Post
9/24/2008 12:31 PM
 

I am struggling trying to find a way to set the value of the text of a label using java script.  The label is within a div seen here:

<div id="TypeSelection" class="mContainer" style ="display:none;" >

 <asp:Label runat = server ID = "lblQuestionType" Text = "Hello" ></asp:Label>   </div>


Currently in javascript I have the following code, but it is not working:


var container = $get("TypeSelection").getElementsByTagName("span");
   var count = container.length;
   for ( var i=0;i<count;i++){
   if  ( container[i].name == 'lblQuestionType')
       container[i].innerText = 'Hi';


Can anyone give me some clue as to how this works with DNN?

Thanks!

 
New Post
9/24/2008 10:48 PM
 

Rather than using

container[i].name == 'lblQuestionType'

you will need to pass the ClientID property of the label into your javascript function and test against the id not name property which may not be present.

Take a look at the source html being generated for your page and you will see what is being used for the name (if present) and the id attributes of the span.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
9/25/2008 8:34 AM
 

How do you do that?  I am not that familiar with javascript and especially the weird things DNN does to the ID values.

 
New Post
10/7/2008 10:01 AM
 

What Bill say that you can view the source file and try looking for the label id name.

I even find a better way, if you lazy to find the id in the source code. On your javascript you can use this

if  ( container[i].name.indexOf('lblQuestionType')>0){

//perform your action here
}

The drawbacks is you have to use a for loop.

Another quick solution: you can declare a variable for javascript in the page load
something like this

lblScript.Text = " var labelID = '" & lblQuestionType.Text & "'"  (this is only partial codes)

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0set label text with javascript in DNN moduleset label text with javascript in DNN module


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