JQuery code in ASP .NET content pages

Posted by user2645830 on Stack Overflow See other posts from Stack Overflow or by user2645830
Published on 2013-10-29T09:29:26Z Indexed on 2013/10/29 9:53 UTC
Read the original article Hit count: 282

Filed under:
|

I have made a very simple sample project where I want to toggle an asp .net calendar control through jquery. Could anyone please point out why it is not working. I have made no changes to master page from the sample project provided for ASP .NET web application.

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master"     AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebApplication5._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="scripts/jquery-1.4.1.min.js">
</script>
<script language="javascript" type="text/javascript">
// <![CDATA[

    function Button1_onclick() {
       alert( $('<%=Calendar1.ClientID%>'));
        $('<%=Calendar1.ClientID%>').toggle();
    }

// ]]>
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
    Welcome to ASP.NET!
</h2>
<p>
    To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET     Website">www.asp.net</a>.
</p>
<input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
    <p>
        You can also find <a href="http://go.microsoft.com/fwlink/?    LinkID=152368&amp;clcid=0x409"
        title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
    </p>
</asp:Content>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ASP.NET