This is a migrated thread and some comments may be shown as answers.

Microsoft JScript runtime error: Object expected

1 Answer 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ravi Prasad Potturi
Top achievements
Rank 1
Ravi Prasad Potturi asked on 14 Sep 2008, 07:02 PM

Hi,

        I am getting  error "Microsoft JScript runtime error: Object expected" when i click on button in ragGrid.Steps are below to reproduce below:

I created radtabstrip and loading user control dynamically.

I am displaying record in radgrid which is present in usercontrol.
User can add/Edit or delete the record from grid.
For that  i place button in Command item template  to Add new record. It will popup radwindow when user click on button.

I am getting java script error "Microsoft JScript runtime error: Object expected" and no clue why it is happening.

Below is my Code for main page, User Control and Rad Window page.

Can you please help me to resolve this issue?

Main Page:

<%

@ Page Language="C#" MasterPageFile="~/DealerFinance.master" AutoEventWireup="true"

CodeFile="DealerDetails.aspx.cs" Inherits="Dealer_DealerDetails" Title="Untitled Page" %>

<%

@ MasterType VirtualPath="~/DealerFinance.master" %>

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<%

@ Register TagPrefix="uc1" TagName="ucDealer" Src="Dealer.ascx" %>

<%

@ Register TagPrefix="uc2" TagName="ucVehicles" Src="Vehicles.ascx" %>

<%

@ Register TagPrefix="uc3" TagName="ucNotes" Src="Notes.ascx" %>

<%

@ Register TagPrefix="uc4" TagName="ucActivities" Src="Activities.ascx" %>

<%

@ Register TagPrefix="uc5" TagName="ucContacts" Src="Contacts.ascx" %>

<%

@ Register TagPrefix="uc6" TagName="ucCollaterals" Src="Collaterals.ascx" %>

<%

@ Register TagPrefix="uc7" TagName="ucBalance" Src="Balance.ascx" %>

<%

@ Register TagPrefix="uc8" TagName="ucInvoice" Src="Invoice.ascx" %>

<%

@ Register TagPrefix="uc9" TagName="ucAudit" Src="Audit.ascx" %>

<%

@ Register TagPrefix="uc10" TagName="ucPayments" Src="Payments.ascx" %>

<

asp:Content ID="Content2" ContentPlaceHolderID="DealerFinancePlaceHolder" runat="Server">

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">

<AjaxSettings>

<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">

<UpdatedControls>

<telerik:AjaxUpdatedControl ControlID="rtsDealerDetails" />

</UpdatedControls>

</telerik:AjaxSetting>

<telerik:AjaxSetting AjaxControlID="rtsDealerDetails">

<UpdatedControls>

<telerik:AjaxUpdatedControl ControlID="pnlDealerDetails" />

</UpdatedControls>

</telerik:AjaxSetting>

</AjaxSettings>

</telerik:RadAjaxManager>

<table width="100%">

<tr>

<td align="center" class="moduleborder">

<table align="center">

<tr>

<td align="left">

<table width="50%">

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

# Resources.DealerFinance.DealerNumber %>

</td>

<td align="left" nowrap="nowrap">

<asp:Label ID="lblDealerNumber" runat="server" SkinID="DisplayNormal">1005</asp:Label>

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

# Resources.DealerFinance.LegalName%>

</td>

<td nowrap="nowrap" align="left">

<asp:Label ID="lblLegalName" runat="server" SkinID="DisplayNormal">Kawasaki Legal Name </asp:Label>

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

# Resources.DealerFinance.Address%>

</td>

<td nowrap="nowrap" align="left">

<asp:Label ID="lblAddress" runat="server" SkinID="DisplayNormal">900 Irvine Blvd dkgjsjfd sfdjl </asp:Label>

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

# Resources.DealerFinance.Address%>

</td>

<td nowrap="nowrap" align="left">

<asp:Label ID="Label1" runat="server" SkinID="DisplayNormal">Righr Place Holder</asp:Label>

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

#Resources.DealerFinance.Address%>

</td>

<td nowrap="nowrap" align="left">

<asp:Label ID="Label2" runat="server" SkinID="DisplayNormal">Right Place Holder</asp:Label>

</td>

</tr>

</table>

</td>

<td align="left">

<table width="50%">

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

# Resources.DealerFinance.DealerName %>

</td>

<td nowrap="nowrap" align="left">

<asp:Label ID="lblDealerName" runat="server" SkinID="DisplayNormal">Kawasaki Dealer Name</asp:Label>

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

# Resources.DealerFinance.KawasakiName %>

</td>

<td nowrap="nowrap" align="left">

<asp:Label ID="lblKawasakiName" runat="server" SkinID="DisplayNormal">Kawasaki</asp:Label>

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

# Resources.DealerFinance.StateCityZip %>

</td>

<td nowrap="nowrap" align="left">

<asp:Label ID="lblStateCityZip" runat="server" SkinID="DisplayNormal">Irvine, CA 92602</asp:Label>

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

# Resources.DealerFinance.Address%>

</td>

<td nowrap="nowrap" align="left">

<asp:Label ID="Label3" runat="server" SkinID="DisplayNormal">Left Place Holder</asp:Label>

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

# Resources.DealerFinance.Address%>

</td>

<td nowrap="nowrap" align="left">

<asp:Label ID="Label4" runat="server" SkinID="DisplayNormal">Left Place Holder</asp:Label>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

<tr>

<td align="center">

<telerik:RadTabStrip ID="rtsDealerDetails" runat="server"

Skin="Web20" AutoPostBack="True" SelectedIndex="9" >

<Tabs>

<telerik:RadTab Text="Details" />

<telerik:RadTab Text="Vehicles" />

<telerik:RadTab Text="Notes" >

<Tabs>

<telerik:RadTab Text="KMFC" />

<telerik:RadTab Text="KMC" />

<telerik:RadTab Text="Special" />

<telerik:RadTab Text="Flash" />

</Tabs>

</telerik:RadTab>

<telerik:RadTab Text="Activities" />

<telerik:RadTab Text="Contacts" />

<telerik:RadTab Text="Collaterals" />

<telerik:RadTab Text="Balance" />

<telerik:RadTab Text="Invoice" />

<telerik:RadTab Text="Audit" />

<telerik:RadTab Text="Payments" Selected="True" />

</Tabs>

</telerik:RadTabStrip>

</td>

</tr>

<tr>

<td>

<telerik:RadAjaxPanel ID="pnlDealerDetails" runat="server"></telerik:RadAjaxPanel>

</td>

</tr>

</table>

</

asp:Content>

Code behind :

using

System;

using

System.Collections;

using

System.Configuration;

using

System.Data;

using

System.Linq;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.HtmlControls;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Xml.Linq;

using

Telerik.Web.UI;

public

partial class Dealer_DealerDetails : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

// rtsDealerDetails.MultiPageID = dealerDetailpages.UniqueID;

Master.SelectedDealerTab = 1;

if (!IsPostBack)

{

rtsDealerDetails.SelectedIndex = 0;

//Response.Write(rtsDealerDetails.SelectedTab.Text);

}

switch (rtsDealerDetails.SelectedIndex)

{

case 0:

//LoadUserControl("Dealer.ascx");

LoadUserControl(

"Dealer.ascx");

break;

case 1:

LoadUserControl(

"Vehicles.ascx");

break;

case 2:

LoadUserControl(

"Notes.ascx");

//LoadControl

break;

}

}

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)

{

 

if (e.Argument == "Rebind")

{

//if (rtsDealerDetails.SelectedTab.Text.Equals("Notes"))

//{

// rtsDealerDetails.SelectedTab.Tabs.se

//}

//grdDealerList.MasterTableView.SortExpressions.Clear();

//grdDealerList.MasterTableView.GroupByExpressions.Clear();

//grdDealerList.DataSource = BindGrid();

//grdDealerList.Rebind();

}

}

public RadTabStrip DealerDetailsTab

{

get

{

return rtsDealerDetails;

}

set

{

}

}

 

public void LoadUserControl(string controlName)

{

if (LatestLoadedControlName != null)

{

Control previousControl = pnlDealerDetails.FindControl(LatestLoadedControlName.Split('.')[0]);

if (previousControl != null)

{

this.pnlDealerDetails.Controls.Remove(previousControl);

}

pnlDealerDetails.Controls.Clear();

}

string userControlID = controlName.Split('.')[0];

Control targetControl = pnlDealerDetails.FindControl(userControlID);

if (targetControl == null)

{

UserControl userControl = (UserControl)this.LoadControl(controlName);

//slashes and tildes are forbidden

userControl.ID = userControlID.Replace(

"/", "").Replace("~", "");

this.pnlDealerDetails.Controls.Add(userControl);

LatestLoadedControlName = controlName;

}

}

 

private string LatestLoadedControlName

{

get

{

return (string)Session["LatestLoadedControlName"];

}

set

{

Session[

"LatestLoadedControlName"] = value;

}

}

}

User Control :

<%

@ Control Language="C#" AutoEventWireup="true" CodeFile="Notes.ascx.cs" Inherits="Dealer_Notes" %>

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<

telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

<script type="text/javascript">

function ShowEditForm(id, rowIndex)

{

var grid = $find("<%= grdNotes.ClientID %>");

var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();

grid.get_masterTableView().selectItem(rowControl,

true);

window.radopen(

"AddEditNotes.aspx", "Add/Edit Notes");

return false;

}

function ShowInsertForm(searchType)

{

window.radopen(

"AddEditNotes.aspx", "Add/Edit Notes");

return false;

}

function refreshGrid(arg)

{

if(!arg)

{

$find(

"<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("Rebind");

}

else

{

$find(

"<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("RebindAndNavigate");

}

}

</script>

</telerik:RadCodeBlock>

<telerik:RadAjaxManagerProxy ID="radAjaxProxy" runat="server" >

<AjaxSettings>

<telerik:AjaxSetting AjaxControlID="radAjaxProxy">

<UpdatedControls>

<telerik:AjaxUpdatedControl ControlID="rtsDealerDetails" />

</UpdatedControls>

</telerik:AjaxSetting>

</AjaxSettings>

</telerik:RadAjaxManagerProxy>

<table>

<tr>

<td align="left">

<!-- <asp:Button ID="tempbtnSearch" runat="server" CausesValidation="false" OnClientClick="LookupParameter()" SkinID="DisplayButton"

Text="Search" /> -->

<!-- <asp:Button ID="btnSearch" runat="server" CausesValidation="false" SkinID="DisplayButton"

OnClientClick = "return ShowInsertForm();" Text="Search" /> -->

&nbsp;

</td>

</tr>

<tr>

<td>

<asp:Button ID="btnAddaa" runat="server" CausesValidation="false" SkinID="DisplayButton"

OnClientClick="return ShowInsertForm('DealersSearch');"

Text=" Add " onclick="btnAddaa_Click" /> &nbsp;

<telerik:RadGrid

ID="grdNotes"

runat="server"

AllowPaging="True"

AllowSorting="True"

PageSize="10"

GridLines="None"

OnItemCommand="RadGrid1_ItemCommand"

OnNeedDataSource="RadGrid1_NeedDataSource"

EnableAJAX="true"

Skin="Vista"

ShowFooter="false"

ShowStatusBar = "false"

>

<PagerStyle Mode="NumericPages" />

<MasterTableView

AutoGenerateColumns="False"

DataKeyNames="ROW_ID,DEALER_NUM"

Width="100%"

CommandItemDisplay="Top"

PageSize="15">

<Columns>

<telerik:GridButtonColumn

DataTextField="DEALER_ID"

CommandArgument="DEALER_ID"

HeaderText="Edit/Delete"

CommandName="Select"

DataTextFormatString = "<nobr>{0}</nobr>"

SortExpression="ROW_ID,DEALER_ID"

ItemStyle-CssClass= "RadGridItemTemplate"

HeaderStyle-Wrap = "false" >

</telerik:GridButtonColumn>

<telerik:GridBoundColumn

DataField="NOTES"

HeaderText="Notes"

ReadOnly="True"

SortExpression="NOTES"

UniqueName="NOTES"

DataFormatString = "<nobr>{0}</nobr>">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn

DataField="START_DT"

HeaderText="Start Date"

SortExpression="START_DT"

UniqueName="START_DT"

DataFormatString = "<nobr>{0}</nobr>">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn

DataField="END_DT"

HeaderText="End Date"

SortExpression="END_DT"

UniqueName="END_DT"

DataFormatString = "<nobr>{0}</nobr>">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn

DataField="DURATION"

HeaderText="Duration"

SortExpression="DURATION"

UniqueName="DURATION"

DataFormatString = "<nobr>{0}</nobr>">

</telerik:GridBoundColumn>

</Columns>

<CommandItemTemplate>

<asp:Button ID="btnAdd" runat="server" CausesValidation="false" SkinID="DisplayButton"

OnClientClick="return ShowInsertForm('DealersSearch');" Text=" Add " /> &nbsp;

</CommandItemTemplate>

</MasterTableView>

</telerik:RadGrid>

</td>

</tr>

</table>

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" Width="625px" Skin="Mac" Height="400px" Left="550px" >

<Windows >

<telerik:RadWindow ID="windowDealerSearch" runat="server" Title="Dealer Search"

ReloadOnShow="true" visiblestatusbar="false"

></telerik:RadWindow>

</Windows>

</telerik:RadWindowManager>


Code Bebind:



using

System;

using

System.Collections;

using

System.Configuration;

using

System.Data;

using

System.Linq;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.HtmlControls;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Xml.Linq;

using

Telerik.Web.UI;

using

System.Data.SqlClient;

public

partial class Dealer_Notes : System.Web.UI.UserControl

{

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

}

}

protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)

{

grdNotes.DataSource = BindGrid();

}

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)

{

if (e.Argument == "Rebind")

{

grdNotes.MasterTableView.SortExpressions.Clear();

grdNotes.MasterTableView.GroupByExpressions.Clear();

grdNotes.DataSource = BindGrid();

grdNotes.Rebind();

}

}

protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)

{

if (e.CommandName == "Select")

{

GridDataItem dataItem = (GridDataItem)e.Item;

string strTxt = dataItem.GetDataKeyValue("ROW_ID").ToString();

string rowID = dataItem.GetDataKeyValue("DEALER_NUM").ToString();

}

}

private DataTable BindGrid()

{

string searchCondition = "";

string sql = "";

//grdDealerList.DataSource = null;

DealSearchFields dealerSeachFieldsObj = (DealSearchFields)Session["DealerSearchFields"];

if (dealerSeachFieldsObj != null)

{

searchCondition = dealerSeachFieldsObj.DealerNumber;

}

else

{

searchCondition =

"";

}

if (searchCondition.Length > 0)

{

sql =

"SELECT ROW_ID ,DEALER_ID ,AREA, TYPE, STATUS, NOTES,START_DT,END_DT,DURATION FROM KF_NOTES_DL where DEALER_ID = '" + searchCondition + "%' order by START_DT";

}

else

{

sql =

"SELECT ROW_ID ,DEALER_ID ,AREA, TYPE, STATUS, NOTES,START_DT,END_DT,DURATION FROM KF_NOTES_DL order by START_DT";

}

SqlDataAdapter adapter = new SqlDataAdapter(sql,

ConfigurationManager.ConnectionStrings["KC_DealerFinanceConnectionString"].ConnectionString);

DataTable dt = new DataTable();

adapter.Fill(dt);

return dt;

}

public DataTable NotesTable

{

get

{

return BindGrid();

}

set { }

}

public RadGrid NotesGrid

{

get

{

return grdNotes;

}

set

{

grdNotes =

value;

}

}

protected void btnAddaa_Click(object sender, EventArgs e)

{

}

}


Rad Window Page :

<%

@ Page Language="C#" AutoEventWireup="true" CodeFile="AddEditNotes.aspx.cs" Inherits="Dealer_AddEditNotes" %>

<!

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>Untitled Page</title>

<script language="javascript" type="text/javascript">

function CloseAndRebind(args)

{

GetRadWindow().Close();

GetRadWindow().BrowserWindow.refreshGrid(args);

}

function GetRadWindow()

{

var oWindow = null;

if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog

else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz as well)

return oWindow;

}

function CancelEdit()

{

GetRadWindow().Close();

}

function SelectAgency(code, name)

{

window.close();

window.opener.ParentFormPostBack(

'','');

window.opener.focus();

}

</script>

</

head>

<

body>

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

<asp:Label ID="InjectScript" runat="server"></asp:Label>

<br />

<table >

<tr align="center" >

<td align="center" nowrap="nowrap" colspan="3" >

<div class="TitleTextNormal" > <%=Resources.DealerFinance.NotesAddEdit%> </div>

</td>

</tr>

<tr>

<td height="10px" align="center" nowrap="nowrap" colspan="3" >

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

=Resources.DealerFinance.DealerNumber%>

</td>

<td align="left">

<asp:Label ID = "lblLegalName" runat="server" SkinID="DisplayNormal">Kawasaki Legal Name </asp:Label>

</td>

<td align="right" width="10px">

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

=Resources.DealerFinance.Employee%>

</td>

<td align="left">

<asp:Label ID = "Label1" runat="server" SkinID="DisplayNormal">Kawasaki Legal Name </asp:Label>

</td>

<td align="right" width="10px">

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

=Resources.DealerFinance.StartDate%>

</td>

<td align="left">

<asp:Label ID = "Label2" runat="server" SkinID="DisplayNormal">11/8/2007 </asp:Label>

</td>

<td align="right" width="10px">

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap" class="labelDisp">

<%

=Resources.DealerFinance.EndDate %>

</td>

<td align="left">

<asp:Label ID = "Label3" runat="server" SkinID="DisplayNormal">12/8/2007 </asp:Label>

</td>

<td align="right" width="10px">

</td>

</tr>

<tr>

<td align="right" nowrap="nowrap">

<%

=Resources.DealerFinance.Notes%>

</td>

<td align="left">

<asp:TextBox ID="txtNotes" runat="server" MaxLength="600" TextMode="MultiLine" Columns="45" Rows="10" Wrap="true"></asp:TextBox>

</td>

<td align="right" width="10px">

</td>

</tr>

<tr>

<td align="center" colspan="2">

<br />

<asp:Button ID="btnSave" runat="server" CausesValidation="false" OnClick="btnSave_Click"

SkinID="DisplayButton" Text=" Save " />

<asp:Button ID="btnDelete" runat="server" CausesValidation="false" OnClick="btnDelete_Click"

SkinID="DisplayButton" Text=" Delete " />

<asp:Button ID="btnCancel" runat="server" CausesValidation="false" OnClick="btnCancel_Click"

SkinID="DisplayButton" Text="Cancel" />

</td>

<td align="right" width="10px">

</td>

</tr>

</table>

</form>

</

body>

</

html>


Code Behind:

using

System;

using

System.Collections;

using

System.Configuration;

using

System.Data;

using

System.Linq;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.HtmlControls;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Xml.Linq;

public

partial class Dealer_AddEditNotes : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

 

protected void btnCancel_Click(object sender, EventArgs e)

{

ClientScript.RegisterStartupScript(Page.GetType(),

"mykey", "CancelEdit();", true);

}

protected void btnDelete_Click(object sender, EventArgs e)

{

ClientScript.RegisterStartupScript(Page.GetType(),

"mykey", "CloseAndRebind();", true);

}

protected void btnSave_Click(object sender, EventArgs e)

{

ClientScript.RegisterStartupScript(Page.GetType(),

"mykey", "CloseAndRebind();", true);

}

}

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 15 Sep 2008, 05:52 AM
Hello Ravi,

Try to temporary replace you RadScriptManager (I suppose you are using it in your Master Page) with regular ScriptManager control.

Let us know whether this helps you avoid the error.

Greetings,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Ravi Prasad Potturi
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or