Dear All,
I am having a masterpage and several contentpages that use this masterpage.
I need to display a javascript popup calendar and gets its value into a textbox in one of the content pages.
The problem is that a content page cannot have the <head> tags and therefore cannot mention the js file, css in it.
It can however have the <script> section and I tried to use it but it doesn't work.
I am calling the js file on the click event of a Imagebutton as below:
<table width="100%" height="0">
<tr>
<td style="width: 91px; height: 10px;" align="right">
<asp:Literal ID="Literal1" runat="server" Text="From Date"></asp:Literal></td>
<td style="width: 84px; height: 10px;" align="right" valign="middle">
<input id="useDateCal_txt_Date" style="WIDTH: 80px; HEIGHT: 14px" type="text" size="9" name="useDateCal:txt_Date2" runat="server" >
</td>
<td align="left" style="width: 9px; height: 10px" valign="middle">
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl ="Calendar_component/calendar.gif" width="30" border="0" style="height: 16px" OnClick="ImageButton1_Click"/></td>
Then I did the following:
I registered the script file in the Click event handler of the Imagebutton as below:
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
string scriptUrl = "~/ClinicalSection/Calendar_component/Calendar.js";
this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "Mykey", scriptUrl);
}
Then I am calling the main function of the js file by adding attributes in the Page_load event as below:
protected void Page_Load(object sender, EventArgs e)
{
//getddllist();
//ImageButton1.Attributes.Add("onclick", "calopen");string calendarJS = String.Format("showCalendarControl('{0}')", useDateCal_txt_Date);ImageButton1.Attributes.Add("onclick", calendarJS);
}
But it doesn't work.What is the problem?
Your help will be highly appreciated.
Thanks.