Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have date picker user control which is placed on master page. when i run application on local machine popup appears to select date and on production server i was able to select date in IE. Now all of sudden date popup is not coming on production server when i debug that application on production server it gives uncaught exception.I get exception in below javascript

var formname = document.getElementById(txtBox).form.name; 

I get nothing in formname variable but same is working before and on local machine. difference i found was ctl00_ prefix was coming on local machine while on production server ctl00 prefix is not coming now so what could be the reason?
I am using ASP.net 2.0 framework. below is my code
Asp.net code :

<asp:textbox id="tbDate" runat="server" Width="104px" CssClass="clsTextBox">        
        <asp:Image  id="imgCal" Visible="True" runat="server"  ImageUrl="../images/calendar.jpg"/>
Code Behind:
protected override void OnPreRender(EventArgs e)
{
  //  base.OnPreRender(e);
    tbDate.Attributes.Add("onkeypress", "javascript:return WriteProtect()");
    imgCal.ImageUrl = "../images/calendar.jpg";

    imgCal.Attributes.Add("onclick", "javascript:cbfshowcalendar('" + imgCal.ClientID + "','" + tbDate.ClientID + "');event.cancelBubble=true;");

    if(!Page.ClientScript.IsStartupScriptRegistered("CalendarJS"))
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "CalendarJS", "<script type='text/javascript'  src='../include/calendar.js'></script>");
    }
}

Javascript :
function cbfshowcalendar(imgObj, txtBox)
{
//The current size of the IFRAME is width=167 and height=185
//var x=eval("document.all." + imgname + ".offsetLeft");
//var y=eval("document.all." + imgname + ".offsetTop");
var objname = txtBox;
var imgname =  imgObj;

var formname = document.getElementById(txtBox).form.name; -- gets nothing in formname 


var x=findPosX(eval("document.all." + imgname));
var y=findPosY(eval("document.all." + imgname));
var max_x = window.screen.width;
var max_y = window.screen.height-100;
. . . .
function cbfloadmefirst(formname, objname)
{
var tempObj;
var tempDate;

tempObj = eval("document." + formname + "." + objname);  -- error on this line
Tags


What I have tried:

i found was ctl00_ prefix was coming on local machine while on production server ctl00 prefix is not coming now so what could be the reason?
Posted
Updated 15-Sep-16 6:01am
v6
Comments
Richard Deeming 15-Sep-16 15:52pm    
Sounds like the server is set up to run your application in a .NET 4.0 AppPool, whereas your local machine is running it in a .NET 2.0 AppPool.
Member 1151923 16-Sep-16 4:05am    
Thanks for reply but it is set to .NET 2.0 only
Richard Deeming 16-Sep-16 8:31am    
The missing ctl00 prefix contradicts that. It's caused by the ClientIDMode, which was added in .NET 4.0:
https://weblog.west-wind.com/posts/2009/Nov/07/ClientIDMode-in-ASPNET-40[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900