Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

  Need Help?  
Professional technical support for DotNetNuke is available from DotNetNuke Corporation.
 


  Ads  
Engage Software - Training Partner for DotNetNuke
 


  Sponsors  

Meet Our Sponsors

Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
AspDotNetStoreFront - E-Commerce by Design - The Leading ASP.NET shopping cart platform for developers!
Click here to go to dev.live.com for Windows Live developer resources
SteadyRain
DataSprings - Great Ideas. Always Flowing.
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  Module javascript issue please help
Previous Previous
 
Next Next
New Post 3/19/2008 12:46 PM
User is offline mjliscio
110 posts
9th Ranked


Module javascript issue please help 
Modified By mjliscio  on 3/19/2008 3:49:37 PM)

Hello all,

I have a DotNetNuke Module set up as follows

                                           Facility ID Number Search    
                                                             Operator Name    
                                                                      Site Name    
                                                                County Name    
                                                                 Region name    

 

Each submit Query button runs a seperate Query based on what is entered into the text box imediatly left of the button.

The query is then ran and the user is shown the results in a grid view.  What I want to be able to do is once I select a text box I want the button imediatly right of the box to get the focus so that the user can enter the information in one of the boxes and then hit enter and run that specific query. 

I decided to add javascript to do this.  I wrote the following javascript

 

<

 

script type ="text/javascript" language = "javascript">

 

function FacIDSelect(){

 

document.getElementById('Button3').focus();

  } // end FacIDSelect

 

</script>

 

 

 

 

 

 

 

 

 

 

this works fine when it is in an asp page, but once I port the asp page over to a module I ge the error Document.GetElementByID(..) is null or not an object.

Upon research of this I found that the error is being caused because DotNetNuke wraps each module in a form tag, and that is causing my control not to be found.  Is there a work around to this.

 

Thanks Mike

 

 

 
New Post 3/19/2008 8:28 PM
User is offline Fooberichu
421 posts
www.seeleyware.com
8th Ranked


Re: Module javascript issue please help 

The problem is that the javascript is assuming that the button really is named Button3... which in a regular page it would be, but in case of a module (or anything in "containers" or master pages for example), it isn't.  It is really going to be something funky like dnn_ctrl123_button3 and the way to find that is to (in VB or C# code behind, use Button3.ClientID).  So how do you get that to output into your javascript?  Have a function within your codebehind like "PopulateScript" or something creative like that and then use a StringBuilder or other string method to build your javascript function and in place of 'Button3' put Button3.ClientID which will output the unique clientside id that will be generated for that button.  Then at the end of building your script call Page.RegisterStartupScript (I can't remember the exact call off the top of my head and not on a computer with Visual Studio on it) and it'll insert your function into the page.

Hopefully that helps... if not I'll be on a computer with some code tomorrow and can post up a snippet (or somebody else may have answered with a snippet by then).


-- Fooberichu
http://www.seeleyware.com
 
New Post 3/20/2008 6:00 AM
User is offline Fooberichu
421 posts
www.seeleyware.com
8th Ranked


Re: Module javascript issue please help 

Ok... so the line would be something like this:

Page.ClientScript.RegisterStartupScript(typeof(myObject), string.Concat("myScript_", this.ModuleId.ToString()), scriptBuilder.ToString());

the myObject would be some object in your project, it could be that page you are loading, for example, the second parameter is just what you are calling the script; I chose to include the module id in case there were multiple instances on the page and perhaps the script is built specifically for each module instance; the third parameter is the script itself, in this case I used a StringBuilder to build the script.

Hopefully that helps you out.


-- Fooberichu
http://www.seeleyware.com
 
New Post 3/20/2008 7:19 AM
User is offline mjliscio
110 posts
9th Ranked


Re: Module javascript issue please help 

Thank you for the response it helped a lot.  Problem solved my solution was a little different then what you posted but along the same lines

 

Dim

myScript As String = "function facIDSelect(){ document.getElementById('" & Button3.ClientID & "').focus(); }"

Page.ClientScript.RegisterClientScriptBlock(Page.GetType,

"ScriptFunction", myScript, True)

Thanks for your help

Mike

 

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  Module javascript issue please help
 


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.

 


ASP.NET Web Hosting for $3.95
3 Month FREE ASP.NET Hosting! FREE Setup! DNN Support! FREE Domain Name! FREE Components! Host multiple websites on 1 plan! 30 Days Money Back Guarantee!
www.dailyrazor.com
Cestus Websites
DotNetNuke websites en services in Nederland. Cestus Websites levert websites, projectmanagent, skins, modules, training en gespecialiseerde hosting op basis van het CMS DotNetNuke.
www.dotnetnuke-websites.nl
FREE Skins, Modules & Control Panel!
Choose how much you want to pay on our Skins, Modules, Containers and Control Panel - Starting from FREE!
www.dnngroup.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP