Tnx for your answer, but still it dose not work!I think my problem is that the js file could not be found and so Calender.setup dosen't work.I realy want it to work,please help me!!
I think my problem is that the js file could not be found and so Calender.setup dosen't work
From solutions explorer in Visual Studio, just drag and drop the javascript file to your head section in ASCX markup. It will create the correct path for you.
farzanehSH
Member
3 Points
9 Posts
Calendar.setup() With javascript Problem
Dec 03, 2012 07:16 AM|LINK
Hi,I have a problemwhen I want to add calender(js files) to ASCX file. it doesn't work,would you please give me a solution? here is my code in ASCX:
(This code is absolutely working fine for an ASPX page but doesn't work in ASCX file)
<script type='text/javascript' src='~/Calendar/fa/jalali-utility.js'></script> <script type='text/javascript' src='~/Calendar/fa/jalali.class.js'></script> <script type='text/javascript' src='~/Calendar/fa/calendar.js'></script> <script type='text/javascript' src='~/Calendar/fa/calendar-fa.js'></script> <script type='text/javascript' src='~/Calendar/fa/calendar-setup.js'></script> <script type='text/javascript' src='~/Calendar/holiday.js'></script> <script type='text/javascript' src='~/Calendar/fa/holidays.js'></script> <script type='text/javascript'> function bodyOnload() { Calendar.setup( {inputField : "<%=FromDate.ClientID %>", ifFormat : "%m/%d/%Y", button : "FromBtn"}); } window.onload = bodyOnload; </script> <input id="FromDate" runat="server" dir="ltr" name="FromDate" type="text" /> <button id="FromBtn" runat="server" type="button">...</button>can any one help me out here.
raju dasa
Star
14410 Points
2451 Posts
Re: Calendar.setup() With javascript Problem
Dec 03, 2012 08:40 AM|LINK
Hi,
You have to use Page.ResolveClientUrl()
like this:
<script type='text/javascript' src='Page.ResolveClientUrl("~/Calendar/fa/jalali.class.js")'></script>
or with Page.ResolveUrl()
check this: http://www.andornot.com/blog/post/ResolveUrl-vs-ResolveClientUrl.aspx
rajudasa.blogspot.com || blog@opera
farzanehSH
Member
3 Points
9 Posts
Re: Calendar.setup() With javascript Problem
Dec 03, 2012 09:35 AM|LINK
Thanks for your reply,this method is not work in ASCX file,it dosent find the files,any idea? it gives me : "file was not found" message.
farzanehSH
Member
3 Points
9 Posts
Re: Calendar.setup() With javascript Problem
Dec 03, 2012 11:35 AM|LINK
Hi,is there any solution?
raju dasa
Star
14410 Points
2451 Posts
Re: Calendar.setup() With javascript Problem
Dec 03, 2012 11:42 AM|LINK
Hi,
since, userControl comes under <body> section, possibly more than once, adding scripts here is not good.
try adding them where required/used pages.
rajudasa.blogspot.com || blog@opera
farzanehSH
Member
3 Points
9 Posts
Re: Calendar.setup() With javascript Problem
Dec 03, 2012 12:22 PM|LINK
tnx,but you mean that I can not use javascripts file in ASCX at all?
raju dasa
Star
14410 Points
2451 Posts
Re: Calendar.setup() With javascript Problem
Dec 03, 2012 12:54 PM|LINK
Hi,
Yes, Exactly.
rajudasa.blogspot.com || blog@opera
Ruchira
All-Star
43050 Points
7036 Posts
MVP
Re: Calendar.setup() With javascript Problem
Dec 03, 2012 03:06 PM|LINK
Hello,
AFAIK, there is nothing prevent you from using JS in ASCX file. It should work as same as in ASPX file.
Since your button is also a server control, you may have to get the client ID of that too.
So rewrite the above code as below,
Calendar.setup({inputField : "<%=FromDate.ClientID %>", ifFormat : "%m/%d/%Y", button : "<%=FromBtn.ClientID%>"});
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.farzanehSH
Member
3 Points
9 Posts
Re: Calendar.setup() With javascript Problem
Dec 08, 2012 07:40 AM|LINK
Tnx for your answer, but still it dose not work!I think my problem is that the js file could not be found and so Calender.setup dosen't work.I realy want it to work,please help me!!
Ruchira
All-Star
43050 Points
7036 Posts
MVP
Re: Calendar.setup() With javascript Problem
Dec 08, 2012 08:53 AM|LINK
From solutions explorer in Visual Studio, just drag and drop the javascript file to your head section in ASCX markup. It will create the correct path for you.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.