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 9:31 AM
 

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 7: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
Extensions Forge Projects - UserExport, ContentDeJour, ePrayer and ImageEditorControl
 
New Post
9/25/2008 5: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 7: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


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

Attend A Webinar
Free Demo Site
Download DotNetNuke Professional Edition Trial
Have Someone Contact Me
Have Someone Contact Me
DotNetNuke Store

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

PowerDNN
r2integrated
Telerik JustCode Free

DotNetNuke Scoop!

Sponsors

DotNetNuke Corporation

DotNetNuke Corp. is the steward of the DotNetNuke open source project, the most widely adopted Web Content Management Platform for building web sites and web applications on Microsoft. Organizations use DotNetNuke to quickly develop and deploy interactive and dynamic web sites, intranets, extranets and web applications. The DotNetNuke platform is available in a free Community and subscription-based Professional and Enterprise Editions with an Elite Support option. DotNetNuke Corp. also operates the DotNetNuke Store where users purchase third party apps for the platform.