I am unable to make this simple JQuery function to fire in sharePoint Foundation.
These are some of the steps I followed from http://sharepointdragons.com/2012/04/18/adding-jquery-to-a-visual-web-part-and-then-implement-parentchild-radio-buttons/
Step 1 : Add the jquery-1.4.1.js file to SiteAssets
Step 2 : Create a Visual Web Part in a Web Farm Solution.
Step 3 : Add the below code
Step 4 : Deploy the web Part on the Server (Successfull as non-jquery functionality is working).
step 5: But the jquery functionality is not working.
Here is all the code of the web part
WebPart1.ascx
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SanctuaryVisualWebPartUserControl.ascx.cs" Inherits="SanctuaryVisualWebPart.SanctuaryVisualWebPart.SanctuaryVisualWebPartUserControl" %>
<%@ Register assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.WebControls" tagprefix="asp" %>
<SharePoint:ScriptLink ID="ScriptLink1" runat="server" name="~sitecollection/SiteAssets/jquery-1.4.1.js " />
<style type="text/css">
.style1
{
width: 100%;
height: 247px;
}
.style2
{
width: 398px;
}
.style3
{
width: 421px;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
alert("Fired using JQuery Document ready");
$("#btnJQ").click(function () {
$("#tboxJQ").val("Fired using JQuery");
alert("Fired using JQuery");
});
});
</script>
<table bgcolor="#CCFFCC" border="3" cellpadding="3" cellspacing="3"
class="style1">
<tr>
<td>
<asp:Button ID="btnJQ" runat="server" Text="JQuery" Width="110px" />
</td>
<td>
<asp:TextBox ID="tboxJQ" runat="server"></asp:TextBox>
</td>
</tr>
</table>
Step 6 :The first alert from document.ready is fired but the next alert from inside the buttonClick is not.
Any help would be greatly appreciated