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

top.$get(..)is null or not an object

4 Answers 94 Views
Window
This is a migrated thread and some comments may be shown as answers.
Priya
Top achievements
Rank 1
Priya asked on 24 Sep 2008, 07:27 AM
Sir
I have a Page, say Page1.aspx.In it a radGrid and link button is placed
When I click on the linkbutton, a radwindow with a usercontrol is loaded.
ie,

in Page1.aspx

function

OpenRadWindowCustomSearch()

{

var oWnd = radopen("Custom_Search_Page.aspx", "RadWindow2" );

oWnd.setSize(700,550)

oWnd.center();

}

Inside Custom_Search_Page.aspx ,I placed a usercontrol ie,
in
 Custom_Search_Page.aspx

<

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

<div>

<uc1:CustomSearch id="uclCustomSearch" runat="server" />

</div>

</form>

That usercontrol contains a button
While clicking on tht button I want to rabind the grid in Page1
 
 I tried with
top.$get("btnRebindGrid").click(); 
 I m gettg the javascript error
'top.$get(..)is null or not an object when i write it in code behind of usercontrol
ie,
Usercontrol.ascx.vb

Protected

Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click

Dim ds As New DataSet()

ds = Custom_SearchBAL.GridDataSource

Dim strFilterExp As String

Dim i As Integer

For i = 0 To ds.Tables(0).Rows.Count - 1

Custom_SearchBAL.SelectedFieldDatatype = ds.Tables(0).Rows(i)(

"Datatype")

strFilterExp = strFilterExp + ds.Tables(0).Rows(i)(

"ANDOR") + ds.Tables(0).Rows(i)("FilterExp")

Next

Custom_SearchBAL.ResultantFilterExp = strFilterExp

Dim strScript As String

strScript =

"<script language=javascript>"

strScript +=

"top.$get('btnRebindGrid').click();"

strScript +=

"<"

strScript +=

"/script>"

Page.RegisterStartupScript(

"MSGE", strScript)

Page1.aspx

<asp:Button ID="btnRebindGrid" runat="server" Text="RebindGrid" style="display:none" />

Page1.aspx.vb

Protected Sub btnRebindGrid_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRebindGrid.Click

WorkDetailsGrid.Rebind()

End Sub

Page1.aspxPage1.aspx.vb

4 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 26 Sep 2008, 03:13 PM
Hello Priya,

Tghe problem comes from the fact that the user control is an INaming Container - this means that it changes the ClientIDs of the controls which are placed inside it. Please, note that this is not related to the RadWindow control but to general ASP.NET knowledge.

What I can suggest is to try passing the client id in this manner: 

top.$get('<%=btnRebindGrid.ClientID').click();
 
Another option is to find the actual client ID of the button by using the IEDevToolBar or Firebug tools and hard-code it.


All the best,
Svetlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Priya
Top achievements
Rank 1
answered on 27 Sep 2008, 05:35 AM
Sir,

When I gave

<%

@ Control Language="VB" AutoEventWireup="false" CodeFile="ab.ascx.vb" Inherits="ab" %>

<script type="text/javascript">

function RebindGrid()

{

top.$get(

'ctl00$ContentPlaceHolder1$btnRebindGrid').click();

}

</script>

<

asp:Button runat="server" Text="Click" OnClientClick="RebindGrid()" />

Its wrkg
But on codebind
I gave the same ie,

Protected

Sub imgbtnSearch_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgbtnSearch.Click

Dim ds As New DataSet()

GridCustomFilter.Rebind()

ds = Custom_SearchBAL.GridDataSource

Dim strFilterExp As String

Dim i As Integer

For i = 0 To ds.Tables(0).Rows.Count - 1

Custom_SearchBAL.SelectedFieldDatatype = ds.Tables(0).Rows(i)(

"Datatype")

strFilterExp = strFilterExp + ds.Tables(0).Rows(i)(

"ANDOR") + ds.Tables(0).Rows(i)("FilterExp")

Next

Custom_SearchBAL.ResultantFilterExp = strFilterExp

ResultantGrid.Rebind()

Dim strScript As String

strScript =

"<script language=javascript>"

strScript += "top.$get('ctl00$ContentPlaceHolder1$btnRebindGrid').click();"

strScript +=

"<"

strScript +=

"/script>"

Page.RegisterStartupScript(

"MSGE", strScript)

End Sub

Its not wrking.Hw to make it wrk on serverside
Thanks...

0
Georgi Tunev
Telerik team
answered on 29 Sep 2008, 06:54 AM
Hi Priya,

  1. Make sure that the JavaScript function is called - put a simple alert in your function and see if it will be executed.
  2. Make sure that indeed, you are using the correct clientID - this can be done if you insert the ClientID directly from the server, e.g.:
    strScript += "top.$get('" + btnRebindGrid.ClientID + "').click();"



Kind regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Priya
Top achievements
Rank 1
answered on 29 Sep 2008, 08:17 AM
At last I got it in another way
But still tht 
top.$get('<%=btnRebindGrid.ClientID').click();
and only

top.$get(

'ctl00$ContentPlaceHolder1$btnRebindGrid').click();
is wrkg for me
.The method thrg which I got my solutin is
On ascx page add new 

beginRequest
and

endRequest
ie

<

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

var ctl;

function pageLoad(sender, args)

{

// register for our events

Sys.WebForms.PageRequestManager.getInstance().remove_beginRequest(beginRequest);

Sys.WebForms.PageRequestManager.getInstance().remove_endRequest(endRequest);

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);

}

function beginRequest(sender, args)

{

//Get Id of Search button

ctl = document.activeElement.id;

}

function endRequest(sender, args)

{

//Trigger event if the active element is search button

if(ctl == "<%=imgbtnSearch.ClientID%>")

{

//if this is not working add 'top.document.'...

top.$get('ctl00$ContentPlaceHolder1$btnRebindGrid').click();

var oWnd = GetRadWindow();

oWnd.Close();

}

}

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 az well)

return oWindow;

}

</script>

 

Tags
Window
Asked by
Priya
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Priya
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or