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.0Module javascript issue please helpModule javascript issue please help
Previous
 
Next
New Post
3/19/2008 3:46 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 11:28 PM
 

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).


-- Jon Seeley
DotNetNuke Modules
Custom DotNetNuke and .NET Development
http://www.seeleyware.com
 
New Post
3/20/2008 9:00 AM
 

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.


-- Jon Seeley
DotNetNuke Modules
Custom DotNetNuke and .NET Development
http://www.seeleyware.com
 
New Post
3/20/2008 10:19 AM
 

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
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Module javascript issue please helpModule javascript issue please help


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