Page view counter

JavaScript and DotNetNuke???

Last post 01-09-2006 4:44 PM by kcabrams. 3 replies.

Sort Posts:

  • JavaScript and DotNetNuke???

    01-09-2006, 2:08 PM
    • Loading...
    • kcabrams
    • Joined on 11-30-2005, 2:25 PM
    • Washington, DC
    • Posts 124
    • Points 522

    I am in the process of writing a bunch of modules for DNN 4.x  Some of these modules use a decent amount of JavaScript.  I noticed that DNN changes the id and name of all of my server controls.  Is there any way to avoid this at all or maybe a work around of some kind?

    example: id="txtFirstName"

    gets changed to

    id="dnn:ctr393:_ctl0:txtFirstName"

    KC Abramson
    www.ORCradio.com
    Web Application Developer
    Integrated Software Solutions, Inc.

    When you're feeling down just remember.....the best things in life are someone else's.
  • Re: JavaScript and DotNetNuke???

    01-09-2006, 4:09 PM
    • Loading...
    • EmperorWal
    • Joined on 06-06-2005, 6:23 PM
    • New York
    • Posts 166
    • Points 792

    That isn't DNN changing the names, that is ASP.NET changing the names. It does this to make sure that each control has a unique ID on the client. Say you had two server controls in an ASP.NET page, each with a textbox with the ID txtFirstName, what should ASP.NET do to make sure all IDs are unique? It builds a unique name out of the Page/Control hierarchy.

    Each ASP.Net Control exposes a property called ClientID which gives you the unique control name that is legal to use on the client. You can dynamically create javascript and pass this ClientID to your script as the value of a JavaScript variable. ASP.NET has a bunch of APIs to help manage the transition from Server to Client programming. It isn't easy, but the plubming is there. Look for APIs like RegisterStartupScript and RegisterClientScriptBlock to find out more.

    Even better is to use the DNN ClientAPI and its methods in ClientAPI.vb, the explanations in ClientAPITests, and the scripts in the JS folder. These wrap the ASP.NET APIs and give you a sturcture for managing your client script.

    Michael Levy
    Are you ready to be heard? WildVoice Network

    Equicast Media

    Accidental Architect
  • Re: JavaScript and DotNetNuke???

    01-09-2006, 4:18 PM
    • Loading...
    • ech01
    • Joined on 09-08-2004, 3:19 PM
    • MN
    • Posts 288
    • Points 1,430
  • Re: JavaScript and DotNetNuke???

    01-09-2006, 4:44 PM
    • Loading...
    • kcabrams
    • Joined on 11-30-2005, 2:25 PM
    • Washington, DC
    • Posts 124
    • Points 522

    Perfect.  Thanks to both of you.  I really thought I was up sh1ts creek there for a second.

    Thanks,

    KC

    KC Abramson
    www.ORCradio.com
    Web Application Developer
    Integrated Software Solutions, Inc.

    When you're feeling down just remember.....the best things in life are someone else's.
Page 1 of 1 (4 items)