Welcome Guest Search | Active Topics | Sign In | Register

Problem when using an external javascript file. Options
Posted: Thursday, April 24, 2008 11:20:28 AM
Rank: Member
Groups: Member

Joined: 4/18/2008
Posts: 19
I took the following js function out of my .ascx file and into a a .js file and now the code is failing.

function ShowMonthPopup(calendar, refLink)
{
g_curCalendar = calendar ? "<%=date1OEDatePicker.ClientID%>" : "<%=date2OEDatePicker.ClientID%>";
var monthPicker = document.getElementById(refLink);
eo_GetObject(g_curCalendar).showContextMenu(monthPicker, "monthContextMenu");
}

How come this last line of this function doesn't work when the function is in an external file?

I put it back into the .ascx and it works great.
eo_support
Posted: Thursday, April 24, 2008 12:10:55 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,084
Hi,

This segment:

"<%=date1OEDatePicker.ClientID%>"

is ASP.NET syntax. It's not JavaScript syntax. So it only works when it is inside an ASP.NET file, such as .aspx or .ascx.

Thanks
Posted: Thursday, April 24, 2008 12:20:41 PM
Rank: Member
Groups: Member

Joined: 4/18/2008
Posts: 19
So I there an alternative call I could use?
eo_support
Posted: Thursday, April 24, 2008 1:05:50 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,084
You just figure out what "<%=date1OEDatePicker.ClientID%>" really is. At runtime, such statement is being pre-processed by ASP.NET first. It evaluates such statements and replaces them with the evaluated result, once it is evaluated, it is pure JavaScript and can be processed by your browser's JavaScript engine. When you want to take ASP.NET out of the equation by separating them into a JavaScript file, you got to do the evaluation by yourself. Usually people do not separate such small segment of JavaScript because the trouble outweighs the benefits.

If you have any more questions regarding this particular topic, you may wish to seek help from other resources. Our support don't mind giving you a few pointers as to where to look, but we generally don't cover through such issues as they are generic ASP.NET programming issues that are not really related to our product. You can find more detailed explanations of our support policy at here:

http://www.essentialobjects.com/Forum/Default.aspx?g=posts&t=1368

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.