1

I have an aspx page associated with master page. In aspx.cs file I tried to call a JavaScript function using following code

//Code behind (aspx.cs)

ClientScript.RegisterClientScriptBlock(Page.GetType(), "javascript", "GetCmpValue()", true);

//aspx page 
<%@ Page Language="C#" MasterPageFile="~/mlayout.Master" AutoEventWireup="true"          CodeBehind="MResults.aspx.cs" Inherits="Predict.MResults" Title="Untitled Page" %>
 //javascript function
 <script type="text/javascript" language="javascript">
   function GetCmpValue()
   {
     var CmpId=$find('bidLoc');
   } 


</script> 

I am receiving an error Microsoft jscript runtime error object expected issue when page run in IE, but in Firefox and chrome you didn't find error message but still there is problem in calling JavaScript function. Could any one help me in resolving this issue.

0

2 Answers 2

1

Assuming that your page is located in a subfolder of your root and this function would work for pages in the root directory.

Add the path to jQuery as ScriptReference to your ScriptManager/ToolkitScriptManager.

For example:

<asp:ScriptManager ID="ScriptManager1" runat="server">
    <Scripts>
       <asp:ScriptReference Path="~/jQuery/js/jquery-1.5.1.min.js" />
       <asp:ScriptReference Path="~/jQuery/js/jquery-ui-1.8.10.custom.min.js" />
    </Scripts>
</asp:ScriptManager>

Here you can use the Tilde(~) to resolve the correct path to your script(from the root-directory).

0

Please try using the below script. This may be of some help.

ScriptManager.RegisterStartupScript(Page, typeof(Page), "closePopup", "alert('close');", true);

Thank you.