AJAX modelpopup extender VS 2008 3.5 - Jscript error

Last post 03-17-2008 8:04 PM by jmsides. 2 replies.

Sort Posts:

  • Crying [:'(] AJAX modelpopup extender VS 2008 3.5 - Jscript error

    03-16-2008, 6:48 PM
    • Loading...
    • jmsides
    • Joined on 06-28-2004, 11:11 AM
    • Posts 5


    I am getting and error from your AJAX Control Modal Popup Extender Demo; Microsoft JScript runtime error: Object expected

    http://www.asp.net/learn/ajax-videos/video-84.aspx

    I have try to get this to work in two different ways;

    First my code as percieved from your demo -
    ---------------------------------------------------------------------------------------------------

    <%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>

    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <link href="project.css" rel="stylesheet" type="text/css" />
        <title>Untitled Page</title>
       
        <script type="text/javascript">
           var styleToSelect;
           function onOk() {
           document.getElementById('Paragraph1').className = styleToSelect;
           }
           </script>
       
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div style="height: 411px">
            <br />
            <p id="Paragraph1">
                Now is the time for all good men to come to the aid of their country.</p>
            <asp:LinkButton ID="LinkButton1" runat="server">Check to change the style</asp:LinkButton>
            <br />
            <asp:Panel ID="Panel1" runat="server"  Height="204px" Style="display: none" CssClass="modalPopup">  --Style="display: none "Width="233px"
                <p>
                    choose the style you like</p>
                <input id="RadioA" type="radio" name="Radio" onclick="styleToSelect" />
                <label class="sampleStyleA" for="RadioA">
                    "Choose this style."</label><br />
                <input id="RadioB" type="radio" name="Radio" onclick="styleToSelect" />
                <label class="sampleStyleB" for="RadioB">
                    "Choose this style."</label><br />
                <input id="RadioC" type="radio" name="Radio" onclick="styleToSelect" />
                <label class="sampleStyleC" for="RadioC">
                    "Choose this style."</label><br />
                <input id="RadioD" type="radio" name="Radio" onclick="styleToSelect" />
                <label class="sampleStyleD" for="RadioD">
                    "Choose this style."</label><br />
                    <br />
                <div align="center">
                <asp:Button ID="okButton" runat="server" Text="OK" />
                <asp:Button ID="cancelButton" runat="server" Text="Cancel" />
                </div>     
                <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
                    TargetControlID="LinkButton1" PopupControlID="Panel1"
                    BackgroundCssClass="modalbackground" CancelControlID="cancelButton"
                    DropShadow="True" OkControlID="okButton" onokscript="onOK()">
                </cc1:ModalPopupExtender>
            </asp:Panel>
        </div>
        </form>
    </body>
    </html>
    ------css code------------------------------------------------------------------------------------------------------------------------------------


    div#DIV1
    {
     position: relative;
     float: right;
     background: yellow;
     padding: 1px;
     
    }

    .asplinkbutton
    {
     background-color: green;
    }
    .watermark
    {
     background: #FFAAFF;
    }

    .popupControl{
     border: 2px solid Black;
     background-color: #AAD4FF;
     position:absolute;
     visibility:hidden;
     border-color:Black;
     border-width:2px;
    }

    .modalPopup
    {
     background-color:#ffffdd;
     border-width:3px;
     border-style:solid;
     border-color:Gray;
     padding:3px;
     width:250px;
    }

    .sampleStyleA 
    {
     background-color:#FFF;
    }
    .sampleStyleB
    {
     background-color:#FFF;
     font-family:Monospace;
     font-size:10pt;
     font-style:italic;
     font-weight:bold;
    }
    .sampleStyleC
    {
     background-color:#ddffdd;
     font-family:sans-serif;
     font-size:10pt;
     font-style:italic;
    }
    .sampleStyleD
    {
     background-color:blue;
     color:white;
     font-family:Arial;
     font-size:10pt;
    }
    .modalBackGround
    {
     background-color:Gray;
    filter:alpha(opacity=70);
    opacity:0.7;
    }


    --------------------------------------------------------------------------------------------------------------------------------------------------


    When I could not get my code to work I copy/past'd Jonathan Shen's post into a new ajax web site (download from your demo site is a diffent project).

    http://forums.asp.net/p/1122791/1762667.aspx

    This code gives me the same error; Microsoft JScript runtime error: Object expected

    I did need to make two changes to the code;

    Johan's code looks like --------------------------------------- 

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1"
                      PopupControlID="PanelContainer" BackgroundCssClass="modalBackground" DropShadow="true"
                       OkControlID="OkButton" OnOkScript="onOk()" CancelControlID="CancelButton"  />

    My code in the new project looks like -----------------------------------------

    <%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

    <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
    TargetControlID="LinkButton1" PopupControlID="Panel1"
    BackgroundCssClass="modalbackground" CancelControlID="cancelButton"
    DropShadow="True" OkControlID="okButton" onokscript="onOK()">
    </cc1:ModalPopupExtender>

     


    Thanks

  • Re: AJAX modelpopup extender VS 2008 3.5 - Jscript error

    03-16-2008, 10:06 PM
    Answer
    • Loading...
    • rajbandi
    • Joined on 03-16-2008, 10:39 PM
    • Australia
    • Posts 4

    ScriptEngine can't find either an object or a method. Javascript is case sensitive,

    javascript method onOk() is not matching with ModalPopup onokscript method, modify 

     onokscript="onOk()"

    Hope it solves ur problem. 

     

     

    Please mark it as answer if my post solves your problem. Thank you in advance!

    Raj Bandi
    MCSD(C#)
  • Re: AJAX modelpopup extender VS 2008 3.5 - Jscript error

    03-17-2008, 8:04 PM
    Answer
    • Loading...
    • jmsides
    • Joined on 06-28-2004, 11:11 AM
    • Posts 5

    Thank you.  I could not see the "k".  I lived in the down under for two years in SA; many years ago.

Page 1 of 1 (3 items)
Microsoft Communities
Page view counter