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.0Javascript and dnn 4Javascript and dnn 4
Previous
 
Next
New Post
3/6/2007 12:36 PM
 
Hi guys, I have a developed a module but would like to do some client side validation to save server resources. I have been programming for many years and never had a problem with client side javascript and think all this expensive server validation rather than client is bewildering...I don't want my server working out if someone has entered something in a textbox and then re-render the page just to show this simple error.

I have tried accessing my textbox in javascript as I have done thousands of times before but this time it is a mission...why have I got "dnn:ctr361" in the front of my usercontrol ID and how do I access the HTML control in Javascript with this bizarre random text in front of it?

DotNetNuke is a great product but simple things that take 5 minutes in the real world take over an hour in dotnetnuke world.
 
New Post
3/6/2007 3:20 PM
 

To explain this let me give a simple example.  Lets say you have a cool module with a textbox on it (say txt1).  Lets say you plan on putting two of these modules on the page at the same time.  How can you distinguish one from the other?  Another example is lets say you have a textbox called txtName in your module.  How can you guarantee that no other modules will be added to that page that also doesn't have txtName in it. 

.NET handles these naming issues with naming containers.  When you place your module on a page, ASP.NET automatically generates a naming container for your controls. 

A common technique is to simply send down the naming container in a client variable (you can use the ClientAPI for this).   If all you need is access to one or two controls on the client, you can just send down the ctl.UniqueID.

Hope this helps.


 
New Post
3/14/2007 11:16 AM
 

Hello,

I'm  new in this forum and I'm just starting to use DNN. I think Tutunka has a point there and im facing exatly the same problem. Would you please explain recomended control validation techniques to use with DNN or give us some examples or links pls.

Thank You,

 
New Post
3/16/2007 3:20 PM
 
Tutunka,

I had exatly the same problem that you describe, and this was my solution i hope it helps:

1)Create a .js file in your module root folder containing the validation ("/DesktopModules/YourModuleName/MyScripts.js"). Like you can see I'm parssing the event's source element ID to get the DNN prefix. The button that detonates the event knows its own DNN id jejeje...

function BibliotecaBusquedaValidator(e)
{
    /*Get source element for FF & IE*/
    var targ
    if (!e) var e = window.event
    if (e.target) targ = e.target
    else if (e.srcElement) targ = e.srcElement      
   
    /*Get DNN Controls prefix*/
    var prefix = targ.id.replace("_SearchButton","");
   
    /*Find Control to validate*/
    var e = document.getElementById( prefix + "_txtWordsToFind");
   
    /*Validation*/
    if(e.value.length<3)
    {
       
 
New Post
3/17/2007 12:58 AM
 
Tutunka wrote
Hi guys, I have a developed a module but would like to do some client side validation to save server resources. I have been programming for many years and never had a problem with client side javascript and think all this expensive server validation rather than client is bewildering...I don't want my server working out if someone has entered something in a textbox and then re-render the page just to show this simple error.

DotNetNuke is a great product but simple things that take 5 minutes in the real world take over an hour in dotnetnuke world.


Hi, yes client side validation is great but what happens when someone turns off javascript?  You get unvalidated user input on the server side - so you must have both

The thing to use is ASP.NET Validation controls, eg RequiredFieldValidator (search msdn for details). They give you both client and server side validation and you they automatically resolve the client side control name (so you dont have any problem with dnn_ctr1_txtMyTextBox anymore)

Btw using validation controls is the recommend way to do things in all ASP.NET apps, and it takes just 5 mins to do - so its not a case of "5 mins in real world, 1 hour in DNN" as you said :)

JK

You know your website is cool, so why not let your users help you by spreading the word on social networking sites - get the DotNetNuke Social Bookmarks Module with 57 different ways to add social bookmarks to your site ... or download the FREE demo right now
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Javascript and dnn 4Javascript and dnn 4


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