Calander Extender and Controls collection Problem

Last post 10-04-2007 10:13 PM by Jonathan Shen – MSFT. 1 replies.

Sort Posts:

  • Calander Extender and Controls collection Problem

    09-29-2007, 5:39 AM
    • Participant
      1,023 point Participant
    • jassimmunir
    • Member since 05-17-2007, 12:14 PM
    • Lahore, Pakistan (Current Location:Kuwait)
    • Posts 193

    hi

    I've seen this problem a lot but could not find suitable solution. Error is "

    The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

    "

    Problem is that if i remove Clander Extender and Tab Pannel from my Page then this problem sloves. I'va removed all that code from My Master Page's Html which i wrote in Code Blocks(<% ... %>).  My Master Page's Html is As Folllow

    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head runat="server" >

    <title>BizLogiX</title>

    <!-- <link href="<% =Request.ApplicationPath.ToString() + "\\acestyle.css" %>" type="text/css" rel="StyleSheet" />

    <link href="<% =Request.ApplicationPath.ToString() + "\\menu.css" %>" type="text/css" rel="StyleSheet" /> -->

     

    <!-- <script type="text/javascript" language="JavaScript" src="JScript/menu.js"></script> -->

    <!-- <script type="text/javascript" language="JavaScript" src="<% =Request.ApplicationPath.ToString() + "\\JScript\\menu1.js" %>"></script>-->

    <script src="JScript/TabBar.js" language="javascript" type=""></script>

     

     

     

    <script type="text/javascript">

    // preload images

    document.ondragstart = function() { return(false); }

    var img_files = [ 'img/top/tab_start.gif',

    'img/top/tab_bg.gif',

    'img/top/tab_end.gif',

    'img/top/tab_start_hover.gif',

    'img/top/tab_bg_hover.gif',

    'img/top/tab_end_hover.gif'

    ];

    var imgs = new Array();

    function preload()

    {

    for( e in img_files )

    {

    imgs[e] =
    new Image();

    imgs[e].src = img_files[e];

    }

    }

    function menu_hover(el)

    {

    var img1;

    var label;

    var img2;

    switch( el.className )

    {

    case 'start':

    img1 = el.childNodes[0];

    label = next(el);

    img2 = next(el,2).childNodes[0];

    break;

    case 'label':

    img1 = previous(el).childNodes[0];

    label = el;

    img2 = next(el).childNodes[0];

    break;

    case 'end':

    img1 = previous(el,2).childNodes[0];

    label = previous(el);

    img2 = el.childNodes[0];

    break;

    }

    img1.src = img1.src.replace(
    '.gif','_hover.gif');

    label.id = 'hover';

    img2.src = img2.src.replace('.gif','_hover.gif');

    }

    function menu_hout(el)

    {

    var img1;

    var label;

    var img2;

    switch( el.className )

    {

    case 'start':

    img1 = el.childNodes[0];

    label = next(el);

    img2 = next(el,2).childNodes[0];

    break;

    case 'label':

    img1 = previous(el).childNodes[0];

    label = el;

    img2 = next(el).childNodes[0];

    break;

    case 'end':

    img1 = previous(el,2).childNodes[0];

    label = previous(el);

    img2 = el.childNodes[0];

    break;

    }

    img1.src = img1.src.replace(
    '_hover.gif','.gif');

    label.id = '';

    img2.src = img2.src.replace('_hover.gif','.gif');

    }

    function menu_click(tab, url_menu, url_main)

    {

    var tab, url, frame;

    window.location.href="Top.asp?tab="+tab;

    if( url_menu ) parent.window.frames['leftFrame'].location.href = url_menu;

    if( url_main ) parent.window.frames['mainFrame'].location.href = url_main;

    }

     

    function next( el , num )

    {

    var num, el;

    if( ! num ) num = 1;

    for(i=0;i<50;i++)

    {

    if( el.nextSibling.tagName == 'TD' )

    {

    num = num-1;

    if(! num) return el.nextSibling;

    }

    el = el.nextSibling;

    }

    return null;

    }

    function previous(el, num)

    {

    var num, el;

    if( ! num ) num = 1;

    for( i=0; i<50; i++ )

    {

    if( el.previousSibling.tagName == 'TD' )

    {

    num = num-1;

    if(!num) return el.previousSibling;

    }

    el = el.previousSibling;

    }

    return null;

    }

    function changeProject(cbo)

    {

    intPROJECT_ID = cbo.options[cbo.selectedIndex].value

    if(intPROJECT_ID=="")

    return false

    return menu_click('99&PROJECT_ID=' + intPROJECT_ID ,'menu/Menu.asp?type=Project&PROJECT_ID=' + intPROJECT_ID, 'Task.asp?PROJECT_ID=' + intPROJECT_ID )

    }

    </script>

    </head>

    <body class="bg" onload="preload()" background="Top.asp_files/GetImg.gif">

    <form id="form1" runat="server">

    <div>

    <table width="100%" height="100%" cellpadding="0" cellspacing="0">

    <tbody>

    <tr >

    <td colspan="2">

    <img class="logo" src="Here i was also using '<%.....%> to get path dynamically'" align="left" style="left: 22px; width: 244px; top: 17px; height: 34px">

    <div class="topAppli">

    <div style="margin-left: 0pt; display: inline; float: right; width: 500px; height: 100px;">

    <div class="myenu" style="height: 100px;">

    <div><b> hello</b> <a href="#" onclick="parent.top.location='logout.asp?lang=EN'" class="logout"> Logout</a></div>

    </div>

    <div id="infoUsager" align="right"> <b></b><br>

    </div>

    </div>

    <!-- <div style="clear: both;"></div>-->

    <div id="menuOnglet">

    <table class="menuContainer" border="0" cellpadding="0" cellspacing="0" width="100%" style="height:100%" >

    <tbody>

    <tr>

    <td align="left" nowrap="nowrap" valign="top" width="100%"><ul>

    <ul>

    <li id="current"><a onclick="menu_click('1&amp;PROJECT_ID=75','menu/Menu.asp?type=Office&amp;d=0','UserTasks.asp')"

    href="accountshome.aspx"><span>Home</span></a> </li>

    <li><a onclick="menu_click('3&amp;PROJECT_ID=75','menu/Menu.asp?type=AdminLtd','Project.asp')"

    href="MessageCenter.aspx"><span>Message Center </span></a> </li>

    <li><a onclick="menu_click('4&amp;PROJECT_ID=75','menu/MenuHelp.asp','/support/4.3/HTML/index.html')"

    href="#"><span>FAQ</span></a> </li>

    </ul>

    </ul></td>

    <!-- <td align="left" valign="top"></td>-->

    </tr>

    </tbody>

    </table>

    </div>

    </div>

    </td>

    <tr style="height:100%">

    <td style="width: 212px; height:100%" onload="init();menu_restore();" class=bgclass>

    <!-- Side Menu Starts -->

     

     

     

    <div class="menu" style="overflow: visible; height: 100%">

    <div id="menu_top"><img src="Images/spacer.gif" alt="" border="0" height="5" width="143"></div>

    <div class="menu1">

     

     

    <div id="sadf" class="item1" onmouseover="this.style.backgroundColor='#EDF2F6';" onmouseout="this.style.backgroundColor='';" onclick="menu_item_toggle(this);"><img class="btn" src="" height="17" width="17"></div>

    <div class="item1_sub">

    <div class="menu2">

     

     

     

    <div id="" class="item2" onmouseover="this.style.backgroundColor='#ffffff';" onmouseout="this.style.backgroundColor='';" onclick="location.href='asdfj';">as;dflkj;</div>

     

     

    </div>

    </div>

     

     

     

     

    </div>

    <div id="menu_bottom" style="overflow: visible; "><img src="Images/GetImg.gif" alt="" border="0" height="5" width="143"></div>

    </div>

     

     

    <!-- Side Menu Ends -->

     

     

     

     

     

     

     

     

     

    </td>

    <td align="center" valign="top" style="width: 100%">

    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

    </asp:ContentPlaceHolder>

    </td>

    </tr>

    </tbody>

    </table>

    </div>

    </form>

    </body>

    </html>

    Please Click “Mark as Answer” on the post that helps you.Thank you!

    Regards:
    Muhammad Jassim Munir
  • Re: Calander Extender and Controls collection Problem

    10-04-2007, 10:13 PM
    Answer

    Hi Jassimmunir,

    I suspect that you want to reference to the Asp.Net Control by using Javascript and want to programmatically add controls to your page, don't you?

    Based on this, my solutions are

    1. Use <%# %> (be embedded at runtime) instead of your <%= %>(be embedded into the ASP.NET output as part of the generated Parse Tree class)
    2. Remove the inline code blocks and JavaScript and move it to your code behind i.e.

             For example:

          string _manageSearch = String.Format( @" 
            function ManageSearch(){{
                    var lbl = document.getElementById(""lblFindAGift"");
                    var txt = document.getElementById(""{0}"");
                    var btn = document.getElementById(""{1}"");

                    .Do Something with it..

            }}",

            txtSearch.ClientID);

    this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ManageSearch", _manageSearch, true);

    Remember: You need to escape the curly brackets otherwise you will get a "String.Format- Exception of type System.Web.HttpUnhandledException was thrown"

    For more details, please visit this two article. ( article1 by Tim and article2 by Rick Strahl).

    If it doesn't work, please feel free to let me know.

    Hope this helps.

    Best regards,

    Jonathan

    Jonathan Shen
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (2 items)