I am just starting to learn jQuery and so I've created the most bare bones sample module for just plain javascript. I used the Simple Dynamic Module template in VS 2008 for DNN 5.0 and used the View.ascx to place a button and a label within a div. Later I was going to try substituting jQuery code.
The following works in IE 7 (when I click the button the word 'Hide' disappears).
I checked to make sure I don't have javascript disabled in Firefox.
So what am I doing wrong?
function ShowHide(divName, OnOff) {
var ele = document.getElementById(divName);
if (ele != null) {
if (OnOff == "on")
ele.style.display = "block";
else
ele.style.display = "none";
}
}
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
DotNetNuke.Framework.jQuery.RequestRegistration()
Dim jQueryEthScriptPath As String = Me.TemplateSourceDirectory & "/SomeScript.js"
Page.ClientScript.RegisterClientScriptInclude("SomeScript", jQueryEthScriptPath)
If Not Page.IsPostBack Then
End If
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
<input id="Button1" type="button" value="button" onclick="ShowHide('myDiv','off');"/>
<div id="MyDiv">
<asp:Label ID="Label1" runat="server" Text="Hide"></asp:Label>
</div>