When i use the below code in webpage (.aspx file), it works fine; but when I use the below in a user control (.ascx file) it does not work.
How to fix this? Do i have to do any modifications in the masterpage.
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ExclusionSwipeCardRequest.ascx.cs" Inherits="ExclusionSwipeCardRequest" %>
<link type="text/css" rel="stylesheet" href="../App_Themes/LMSTheme/jquery-ui-1.8.16.custom.css" />
<script type="text/javascript" src="../Scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="../Scripts/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" language="javascript">
$(function() {
$("#txtFromDate").datepicker({ dateFormat: 'mm-dd-yy', changeMonth: true, changeYear: true });
});
</script>
<asp:TextBox ID="txtFromDate" MaxLength="10" runat="server" autocomplete="off" ToolTip="Enter From Date"></asp:TextBox>
I might suggest that your paths have changed, which would mean that the
src/hrefvalue of the script/CSS imports are wrong.Rather than using relative paths that jump up directories, you could try qualifying the path from the root of the website (starting the URL with a forward-slash
/), such that:Obviously if there are any paths between the root and the
Scriptsfolder, you would need to specify it, for example:Also worth mentioning is that although control ID prefixing can be managed (even turned off in .NET4), generally server-side controls have IDs in the page that have been concocted by their parent container, such as:
If you weren’t using a server-side control in the page initially, you might want to check you haven’t introduced an issue with jQuery finding the control in the rendered page.